lists.osmocom.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
List overview
Download
gerrit-log
July 2022
----- 2025 -----
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
gerrit-log@lists.osmocom.org
3 participants
2175 discussions
Start a n
N
ew thread
Change in osmocom-bb[master]: trxcon: introduce and use struct 'trxcon_inst'
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28667
) Change subject: trxcon: introduce and use struct 'trxcon_inst' ...................................................................... trxcon: introduce and use struct 'trxcon_inst' trxcon consists of the following three main components: * the L1 TDMA scheduler (libl1sched), * L1 interface (TRXC/TRXD over UDP), * L2 interface (L1CTL). In [1] and [2] the L1 scheduler was abstracted out from both L1 and L2 interfaces and separated into a library, so it does not use the TRXC/TRXD nor L1CTL related API directly. This change is the next step towards the goal of having all three components abstracted from each other. Moreover, this patch brings us closer to another goal of being able to support multiple L1CTL connections (each having its own scheduler). The idea is to give both L1 and L2 interfaces access to the 'trxcon_inst' structure, which basically groups all three components mentioned above into a single piece. The end goal is to eliminate direct interaction between the interfaces, and the scheduler, so that one could easily replace TRXC/TRXD and/or L1CTL with something else. Change-Id: I23319951c56577085e1092669b5534f9d6bda48d Related: [1] I31f77976a7a225ef292fe6dcd583513aec97ed44 Related: [2] I001fb7bc2663eea308b5a8882746ed9863f2c2f8 --- M src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h M src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h M src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h M src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h M src/host/trxcon/src/l1ctl.c M src/host/trxcon/src/l1ctl_link.c M src/host/trxcon/src/sched_trx.c M src/host/trxcon/src/trx_if.c M src/host/trxcon/src/trxcon.c 9 files changed, 181 insertions(+), 119 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/67/28667/1 diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h index 4604e27..5cfcc10 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h @@ -17,9 +17,6 @@ */ #define L1CTL_MSG_LEN_FIELD 2 -/* Forward declaration to avoid mutual include */ -struct trx_instance; - enum l1ctl_fsm_states { L1CTL_STATE_IDLE = 0, L1CTL_STATE_CONNECTED, @@ -30,11 +27,8 @@ struct osmo_fd listen_bfd; struct osmo_wqueue wq; - /* Scheduler for this interface */ - struct l1sched_state *sched; - - /* Bind TRX instance */ - struct trx_instance *trx; + /* Some private data */ + void *priv; /* L1CTL handlers specific */ struct osmo_timer_list fbsb_timer; diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h b/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h index 7b96f6d..2969410 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h @@ -366,6 +366,8 @@ struct l1sched_ts *ts[TRX_TS_COUNT]; /*! BSIC value learned from SCH bursts */ uint8_t bsic; + /*! Some private data */ + void *priv; }; extern const struct l1sched_lchan_desc l1sched_lchan_desc[_L1SCHED_CHAN_MAX]; @@ -373,7 +375,7 @@ enum gsm_phys_chan_config config, int tn); /* Scheduler management functions */ -struct l1sched_state *l1sched_alloc(void *ctx, uint32_t fn_advance); +struct l1sched_state *l1sched_alloc(void *ctx, uint32_t fn_advance, void *priv); void l1sched_reset(struct l1sched_state *sched, bool reset_clock); void l1sched_free(struct l1sched_state *sched); diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h index 4a59d67..26c7829 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h @@ -12,8 +12,6 @@ /* Forward declaration to avoid mutual include */ struct l1sched_burst_req; -struct l1sched_state; -struct l1ctl_link; enum trx_fsm_states { TRX_STATE_OFFLINE = 0, @@ -41,11 +39,8 @@ uint8_t tx_power; int8_t ta; - /* Scheduler for this interface */ - struct l1sched_state *sched; - - /* Bind L1CTL link */ - struct l1ctl_link *l1l; + /* Some private data */ + void *priv; }; struct trx_ctrl_msg { diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h index f66a628..6cec162 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h @@ -2,7 +2,9 @@ #define GEN_MASK(state) (0x01 << state) -extern struct osmo_fsm_inst *trxcon_fsm; +struct l1sched_state; +struct trx_instance; +struct l1ctl_link; enum trxcon_fsm_states { TRXCON_STATE_IDLE = 0, @@ -18,3 +20,16 @@ TRX_EVENT_RSP_ERROR, TRX_EVENT_OFFLINE, }; + +struct trxcon_inst { + struct osmo_fsm_inst *fi; + + /* The L1 scheduler */ + struct l1sched_state *sched; + /* L1/L2 interfaces */ + struct trx_instance *trx; + struct l1ctl_link *l1l; +}; + +struct trxcon_inst *trxcon_inst_alloc(void *ctx); +void trxcon_inst_free(struct trxcon_inst *trxcon); diff --git a/src/host/trxcon/src/l1ctl.c b/src/host/trxcon/src/l1ctl.c index 5db9945..da66f35 100644 --- a/src/host/trxcon/src/l1ctl.c +++ b/src/host/trxcon/src/l1ctl.c @@ -42,6 +42,7 @@ #include <osmocom/bb/trxcon/trx_if.h> #include <osmocom/bb/trxcon/l1sched.h> +#include <osmocom/bb/trxcon/trxcon.h> static const char *arfcn2band_name(uint16_t arfcn) { @@ -296,6 +297,7 @@ static void fbsb_timer_cb(void *data) { struct l1ctl_link *l1l = (struct l1ctl_link *) data; + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_info_dl *dl; struct msgb *msg; @@ -303,12 +305,13 @@ if (msg == NULL) return; - LOGP(DL1C, LOGL_NOTICE, "FBSB timer fired for ARFCN %u\n", l1l->trx->band_arfcn &~ ARFCN_FLAG_MASK); + LOGP(DL1C, LOGL_NOTICE, "FBSB timer fired for ARFCN %u\n", + trxcon->trx->band_arfcn &~ ARFCN_FLAG_MASK); dl = put_dl_info_hdr(msg, NULL); /* Fill in current ARFCN */ - dl->band_arfcn = htons(l1l->trx->band_arfcn); + dl->band_arfcn = htons(trxcon->trx->band_arfcn); fbsb_conf_make(msg, 255, 0); @@ -320,6 +323,7 @@ static int l1ctl_rx_fbsb_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; enum gsm_phys_chan_config ch_config; struct l1ctl_fbsb_req *fbsb; uint16_t band_arfcn; @@ -343,28 +347,28 @@ band_arfcn &~ ARFCN_FLAG_MASK); /* Reset scheduler and clock counter */ - l1sched_reset(l1l->sched, true); + l1sched_reset(trxcon->sched, true); /* Configure a single timeslot */ - l1sched_configure_ts(l1l->sched, 0, ch_config); + l1sched_configure_ts(trxcon->sched, 0, ch_config); /* Ask SCH handler to send L1CTL_FBSB_CONF */ l1l->fbsb_conf_sent = false; /* Only if current ARFCN differs */ - if (l1l->trx->band_arfcn != band_arfcn) { + if (trxcon->trx->band_arfcn != band_arfcn) { /* Update current ARFCN */ - l1l->trx->band_arfcn = band_arfcn; + trxcon->trx->band_arfcn = band_arfcn; /* Tune transceiver to required ARFCN */ - trx_if_cmd_rxtune(l1l->trx, band_arfcn); - trx_if_cmd_txtune(l1l->trx, band_arfcn); + trx_if_cmd_rxtune(trxcon->trx, band_arfcn); + trx_if_cmd_txtune(trxcon->trx, band_arfcn); } /* Transceiver might have been powered on before, e.g. * in case of sending L1CTL_FBSB_REQ due to signal loss. */ - if (!l1l->trx->powered_up) - trx_if_cmd_poweron(l1l->trx); + if (!trxcon->trx->powered_up) + trx_if_cmd_poweron(trxcon->trx); /* Start FBSB expire timer */ l1l->fbsb_timer.data = l1l; @@ -381,6 +385,7 @@ static int l1ctl_rx_pm_req(struct l1ctl_link *l1l, struct msgb *msg) { uint16_t band_arfcn_start, band_arfcn_stop; + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_pm_req *pmr; int rc = 0; @@ -402,7 +407,7 @@ band_arfcn_stop &~ ARFCN_FLAG_MASK); /* Send measurement request to transceiver */ - rc = trx_if_cmd_measure(l1l->trx, band_arfcn_start, band_arfcn_stop); + rc = trx_if_cmd_measure(trxcon->trx, band_arfcn_start, band_arfcn_stop); exit: msgb_free(msg); @@ -411,6 +416,7 @@ static int l1ctl_rx_reset_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_reset *res; int rc = 0; @@ -428,12 +434,12 @@ switch (res->type) { case L1CTL_RES_T_FULL: /* TODO: implement trx_if_reset() */ - trx_if_cmd_poweroff(l1l->trx); - trx_if_cmd_echo(l1l->trx); + trx_if_cmd_poweroff(trxcon->trx); + trx_if_cmd_echo(trxcon->trx); /* Fall through */ case L1CTL_RES_T_SCHED: - l1sched_reset(l1l->sched, true); + l1sched_reset(trxcon->sched, true); break; default: LOGP(DL1C, LOGL_ERROR, "Unknown L1CTL_RESET_REQ type\n"); @@ -465,6 +471,7 @@ static int l1ctl_rx_ccch_mode_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; enum gsm_phys_chan_config ch_config; struct l1ctl_ccch_mode_req *req; struct l1sched_ts *ts; @@ -482,7 +489,7 @@ req->ccch_mode); /* TODO: add value-string for ccch_mode */ /* Make sure that TS0 is allocated and configured */ - ts = l1l->sched->ts[0]; + ts = trxcon->sched->ts[0]; if (ts == NULL || ts->mf_layout == NULL) { LOGP(DL1C, LOGL_ERROR, "TS0 is not configured"); rc = -EINVAL; @@ -494,7 +501,7 @@ /* Do nothing if the current mode matches required */ if (ts->mf_layout->chan_config != ch_config) - rc = l1sched_configure_ts(l1l->sched, 0, ch_config); + rc = l1sched_configure_ts(trxcon->sched, 0, ch_config); /* Confirm reconfiguration */ if (!rc) @@ -507,6 +514,7 @@ static int l1ctl_rx_rach_req(struct l1ctl_link *l1l, struct msgb *msg, bool ext) { + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_info_ul *ul; struct l1sched_ts_prim *prim; struct l1sched_ts_prim_rach rach; @@ -553,7 +561,7 @@ * Indicated timeslot needs to be configured. */ prim_type = ext ? L1SCHED_PRIM_RACH11 : L1SCHED_PRIM_RACH8; - prim = l1sched_prim_push(l1l->sched, prim_type, ul->chan_nr, ul->link_id, + prim = l1sched_prim_push(trxcon->sched, prim_type, ul->chan_nr, ul->link_id, (const uint8_t *)&rach, sizeof(rach)); if (prim == NULL) rc = -ENOMEM; @@ -624,6 +632,7 @@ static int l1ctl_rx_dm_est_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; enum gsm_phys_chan_config config; struct l1ctl_dm_est_req *est_req; struct l1ctl_info_ul *ul; @@ -651,15 +660,15 @@ /* Frequency hopping? */ if (est_req->h) - rc = l1ctl_proc_est_req_h1(l1l->trx, &est_req->h1); + rc = l1ctl_proc_est_req_h1(trxcon->trx, &est_req->h1); else /* Single ARFCN */ - rc = l1ctl_proc_est_req_h0(l1l->trx, &est_req->h0); + rc = l1ctl_proc_est_req_h0(trxcon->trx, &est_req->h0); if (rc) goto exit; /* Configure requested TS */ - rc = l1sched_configure_ts(l1l->sched, tn, config); - ts = l1l->sched->ts[tn]; + rc = l1sched_configure_ts(trxcon->sched, tn, config); + ts = trxcon->sched->ts[tn]; if (rc) { rc = -EINVAL; goto exit; @@ -683,10 +692,12 @@ static int l1ctl_rx_dm_rel_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; + LOGP(DL1C, LOGL_NOTICE, "Received L1CTL_DM_REL_REQ, resetting scheduler\n"); /* Reset scheduler */ - l1sched_reset(l1l->sched, false); + l1sched_reset(trxcon->sched, false); msgb_free(msg); return 0; @@ -698,6 +709,7 @@ static int l1ctl_rx_dt_req(struct l1ctl_link *l1l, struct msgb *msg, bool traffic) { + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_info_ul *ul; struct l1sched_ts_prim *prim; uint8_t chan_nr, link_id; @@ -720,7 +732,7 @@ chan_nr, link_id, payload_len); /* Push this primitive to transmit queue */ - prim = l1sched_prim_push(l1l->sched, L1SCHED_PRIM_DATA, + prim = l1sched_prim_push(trxcon->sched, L1SCHED_PRIM_DATA, chan_nr, link_id, ul->payload, payload_len); if (prim == NULL) rc = -ENOMEM; @@ -731,6 +743,7 @@ static int l1ctl_rx_param_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_par_req *par_req; struct l1ctl_info_ul *ul; @@ -741,12 +754,12 @@ "(ta=%d, tx_power=%u)\n", par_req->ta, par_req->tx_power); /* Instruct TRX to use new TA value */ - if (l1l->trx->ta != par_req->ta) { - trx_if_cmd_setta(l1l->trx, par_req->ta); - l1l->trx->ta = par_req->ta; + if (trxcon->trx->ta != par_req->ta) { + trx_if_cmd_setta(trxcon->trx, par_req->ta); + trxcon->trx->ta = par_req->ta; } - l1l->trx->tx_power = par_req->tx_power; + trxcon->trx->tx_power = par_req->tx_power; msgb_free(msg); return 0; @@ -754,6 +767,7 @@ static int l1ctl_rx_tch_mode_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_tch_mode_req *req; struct l1sched_lchan_state *lchan; struct l1sched_ts *ts; @@ -765,9 +779,9 @@ "(tch_mode=%u, audio_mode=%u)\n", req->tch_mode, req->audio_mode); /* Iterate over timeslot list */ - for (tn = 0; tn < ARRAY_SIZE(l1l->sched->ts); tn++) { + for (tn = 0; tn < ARRAY_SIZE(trxcon->sched->ts); tn++) { /* Timeslot is not allocated */ - ts = l1l->sched->ts[tn]; + ts = trxcon->sched->ts[tn]; if (ts == NULL) continue; @@ -797,6 +811,7 @@ static int l1ctl_rx_crypto_req(struct l1ctl_link *l1l, struct msgb *msg) { + struct trxcon_inst *trxcon = l1l->priv; struct l1ctl_crypto_req *req; struct l1ctl_info_ul *ul; struct l1sched_ts *ts; @@ -813,7 +828,7 @@ tn = ul->chan_nr & 0x7; /* Make sure that required TS is allocated and configured */ - ts = l1l->sched->ts[tn]; + ts = trxcon->sched->ts[tn]; if (ts == NULL || ts->mf_layout == NULL) { LOGP(DL1C, LOGL_ERROR, "TS %u is not configured\n", tn); rc = -EINVAL; diff --git a/src/host/trxcon/src/l1ctl_link.c b/src/host/trxcon/src/l1ctl_link.c index b10d9da..294ed6f 100644 --- a/src/host/trxcon/src/l1ctl_link.c +++ b/src/host/trxcon/src/l1ctl_link.c @@ -136,6 +136,7 @@ static int l1ctl_link_accept(struct osmo_fd *bfd, unsigned int flags) { struct l1ctl_link *l1l = (struct l1ctl_link *) bfd->data; + struct trxcon_inst *trxcon = l1l->priv; struct osmo_fd *conn_bfd = &l1l->wq.bfd; struct sockaddr_un un_addr; socklen_t len; @@ -170,7 +171,7 @@ return -1; } - osmo_fsm_inst_dispatch(trxcon_fsm, L1CTL_EVENT_CONNECT, l1l); + osmo_fsm_inst_dispatch(trxcon->fi, L1CTL_EVENT_CONNECT, l1l); osmo_fsm_inst_state_chg(l1l->fsm, L1CTL_STATE_CONNECTED, 0, 0); LOGP(DL1C, LOGL_NOTICE, "L1CTL has a new connection\n"); @@ -205,6 +206,7 @@ int l1ctl_link_close_conn(struct l1ctl_link *l1l) { struct osmo_fd *conn_bfd = &l1l->wq.bfd; + struct trxcon_inst *trxcon = l1l->priv; if (conn_bfd->fd <= 0) return -EINVAL; @@ -217,7 +219,7 @@ /* Clear pending messages */ osmo_wqueue_clear(&l1l->wq); - osmo_fsm_inst_dispatch(trxcon_fsm, L1CTL_EVENT_DISCONNECT, l1l); + osmo_fsm_inst_dispatch(trxcon->fi, L1CTL_EVENT_DISCONNECT, l1l); osmo_fsm_inst_state_chg(l1l->fsm, L1CTL_STATE_IDLE, 0, 0); return 0; diff --git a/src/host/trxcon/src/sched_trx.c b/src/host/trxcon/src/sched_trx.c index d3a0a54..1c0910e 100644 --- a/src/host/trxcon/src/sched_trx.c +++ b/src/host/trxcon/src/sched_trx.c @@ -150,7 +150,7 @@ l1sched_handle_burst_req(sched, &br[tn]); } -struct l1sched_state *l1sched_alloc(void *ctx, uint32_t fn_advance) +struct l1sched_state *l1sched_alloc(void *ctx, uint32_t fn_advance, void *priv) { struct l1sched_state *sched; @@ -164,6 +164,7 @@ /* .clock_timer is set up in l1sched_clck_correct() */ .clock_cb = &sched_frame_clck_cb, .fn_counter_advance = fn_advance, + .priv = priv, }; return sched; diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c index 9984e0e..34d8874 100644 --- a/src/host/trxcon/src/trx_if.c +++ b/src/host/trxcon/src/trx_if.c @@ -161,6 +161,7 @@ static void trx_ctrl_timer_cb(void *data) { struct trx_instance *trx = (struct trx_instance *) data; + struct trxcon_inst *trxcon = trx->priv; struct trx_ctrl_msg *tcm; /* Queue may be cleaned at this moment */ @@ -173,7 +174,7 @@ if (++tcm->retry_cnt > 3) { LOGP(DTRX, LOGL_NOTICE, "Transceiver offline\n"); osmo_fsm_inst_state_chg(trx->fsm, TRX_STATE_OFFLINE, 0, 0); - osmo_fsm_inst_dispatch(trxcon_fsm, TRX_EVENT_OFFLINE, trx); + osmo_fsm_inst_dispatch(trxcon->fi, TRX_EVENT_OFFLINE, trx); return; } @@ -366,6 +367,7 @@ static void trx_if_measure_rsp_cb(struct trx_instance *trx, char *resp) { + struct trxcon_inst *trxcon = trx->priv; unsigned int freq10; uint16_t band_arfcn; int dbm; @@ -385,7 +387,7 @@ } /* Send L1CTL_PM_CONF */ - l1ctl_tx_pm_conf(trx->l1l, band_arfcn, dbm, + l1ctl_tx_pm_conf(trxcon->l1l, band_arfcn, dbm, band_arfcn == trx->pm_band_arfcn_stop); /* Schedule a next measurement */ @@ -475,6 +477,7 @@ static int trx_ctrl_read_cb(struct osmo_fd *ofd, unsigned int what) { struct trx_instance *trx = ofd->data; + struct trxcon_inst *trxcon = trx->priv; struct trx_ctrl_msg *tcm; int resp, rsp_len; char buf[TRXC_BUF_SIZE], *p; @@ -557,7 +560,7 @@ rsp_error: /* Notify higher layers about the problem */ - osmo_fsm_inst_dispatch(trxcon_fsm, TRX_EVENT_RSP_ERROR, trx); + osmo_fsm_inst_dispatch(trxcon->fi, TRX_EVENT_RSP_ERROR, trx); return -EIO; } @@ -586,6 +589,7 @@ static int trx_data_rx_cb(struct osmo_fd *ofd, unsigned int what) { struct trx_instance *trx = ofd->data; + struct trxcon_inst *trxcon = trx->priv; struct l1sched_meas_set meas; uint8_t buf[TRXD_BUF_SIZE]; sbit_t bits[148]; @@ -635,11 +639,11 @@ }; /* Poke scheduler */ - l1sched_handle_rx_burst(trx->sched, tn, fn, bits, 148, &meas); + l1sched_handle_rx_burst(trxcon->sched, tn, fn, bits, 148, &meas); /* Correct local clock counter */ if (fn % 51 == 0) - l1sched_clck_handle(trx->sched, fn); + l1sched_clck_handle(trxcon->sched, fn); return 0; } diff --git a/src/host/trxcon/src/trxcon.c b/src/host/trxcon/src/trxcon.c index e7a7c1e..96b4cd1 100644 --- a/src/host/trxcon/src/trxcon.c +++ b/src/host/trxcon/src/trxcon.c @@ -62,15 +62,10 @@ int daemonize; int quit; - /* The scheduler */ - struct l1sched_state *sched; - /* L1CTL specific */ - struct l1ctl_link *l1l; const char *bind_socket; /* TRX specific */ - struct trx_instance *trx; const char *trx_bind_ip; const char *trx_remote_ip; uint16_t trx_base_port; @@ -88,7 +83,6 @@ }; static void *tall_trxcon_ctx = NULL; -struct osmo_fsm_inst *trxcon_fsm; static void trxcon_gsmtap_send(const struct l1sched_lchan_desc *lchan_desc, uint32_t fn, uint8_t tn, uint16_t band_arfcn, @@ -112,13 +106,15 @@ int l1sched_handle_config_req(struct l1sched_state *sched, const struct l1sched_config_req *cr) { + struct trxcon_inst *trxcon = sched->priv; + switch (cr->type) { case L1SCHED_CFG_PCHAN_COMB: - return trx_if_cmd_setslot(app_data.trx, + return trx_if_cmd_setslot(trxcon->trx, cr->pchan_comb.tn, cr->pchan_comb.pchan); default: - LOGPFSML(trxcon_fsm, LOGL_ERROR, + LOGPFSML(trxcon->fi, LOGL_ERROR, "Unhandled config request (type 0x%02x)\n", cr->type); return -ENODEV; } @@ -127,7 +123,9 @@ int l1sched_handle_burst_req(struct l1sched_state *sched, const struct l1sched_burst_req *br) { - return trx_if_tx_burst(app_data.trx, br); + struct trxcon_inst *trxcon = sched->priv; + + return trx_if_tx_burst(trxcon->trx, br); } /* External L2 API for the scheduler */ @@ -138,6 +136,8 @@ { const struct l1sched_meas_set *meas = &lchan->meas_avg; const struct l1sched_lchan_desc *lchan_desc; + struct l1sched_state *sched = lchan->ts->sched; + struct trxcon_inst *trxcon = sched->priv; struct l1ctl_info_dl dl_hdr; int rc; @@ -147,7 +147,7 @@ .chan_nr = lchan_desc->chan_nr | lchan->ts->index, .link_id = lchan_desc->link_id, .frame_nr = htonl(meas->fn), - .band_arfcn = htons(app_data.trx->band_arfcn), + .band_arfcn = htons(trxcon->trx->band_arfcn), .fire_crc = data_len > 0 ? 0 : 2, .rx_level = dbm2rxlev(meas->rssi), .num_biterr = n_errors, @@ -157,29 +157,28 @@ switch (dt) { case L1SCHED_DT_TRAFFIC: case L1SCHED_DT_PACKET_DATA: - rc = l1ctl_tx_dt_ind(app_data.l1l, &dl_hdr, data, data_len, true); + rc = l1ctl_tx_dt_ind(trxcon->l1l, &dl_hdr, data, data_len, true); break; case L1SCHED_DT_SIGNALING: - rc = l1ctl_tx_dt_ind(app_data.l1l, &dl_hdr, data, data_len, false); + rc = l1ctl_tx_dt_ind(trxcon->l1l, &dl_hdr, data, data_len, false); break; case L1SCHED_DT_OTHER: if (lchan->type == L1SCHED_SCH) { - if (app_data.l1l->fbsb_conf_sent) + if (trxcon->l1l->fbsb_conf_sent) return 0; - rc = l1ctl_tx_fbsb_conf(app_data.l1l, 0, &dl_hdr, - lchan->ts->sched->bsic); + rc = l1ctl_tx_fbsb_conf(trxcon->l1l, 0, &dl_hdr, sched->bsic); break; } /* fall through */ default: - LOGPFSML(trxcon_fsm, LOGL_ERROR, + LOGPFSML(trxcon->fi, LOGL_ERROR, "Unhandled L2 DATA.ind (type 0x%02x)\n", dt); return -ENODEV; } if (data != NULL && data_len > 0) { trxcon_gsmtap_send(lchan_desc, meas->fn, lchan->ts->index, - app_data.trx->band_arfcn, meas->rssi, 0, + trxcon->trx->band_arfcn, meas->rssi, 0, data, data_len); } @@ -190,6 +189,8 @@ uint32_t fn, enum l1sched_data_type dt) { const struct l1sched_lchan_desc *lchan_desc; + struct l1sched_state *sched = lchan->ts->sched; + struct trxcon_inst *trxcon = sched->priv; struct l1ctl_info_dl dl_hdr; const uint8_t *data; uint8_t ra_buf[2]; @@ -202,18 +203,18 @@ .chan_nr = lchan_desc->chan_nr | lchan->ts->index, .link_id = lchan_desc->link_id, .frame_nr = htonl(fn), - .band_arfcn = htons(app_data.trx->band_arfcn), + .band_arfcn = htons(trxcon->trx->band_arfcn), }; switch (dt) { case L1SCHED_DT_TRAFFIC: case L1SCHED_DT_PACKET_DATA: - rc = l1ctl_tx_dt_conf(app_data.l1l, &dl_hdr, true); + rc = l1ctl_tx_dt_conf(trxcon->l1l, &dl_hdr, true); data_len = lchan->prim->payload_len; data = lchan->prim->payload; break; case L1SCHED_DT_SIGNALING: - rc = l1ctl_tx_dt_conf(app_data.l1l, &dl_hdr, false); + rc = l1ctl_tx_dt_conf(trxcon->l1l, &dl_hdr, false); data_len = lchan->prim->payload_len; data = lchan->prim->payload; break; @@ -223,7 +224,7 @@ rach = (struct l1sched_ts_prim_rach *)lchan->prim->payload; - rc = l1ctl_tx_rach_conf(app_data.l1l, app_data.trx->band_arfcn, fn); + rc = l1ctl_tx_rach_conf(trxcon->l1l, trxcon->trx->band_arfcn, fn); if (lchan->prim->type == L1SCHED_PRIM_RACH11) { ra_buf[0] = (uint8_t)(rach->ra >> 3); ra_buf[1] = (uint8_t)(rach->ra & 0x07); @@ -238,13 +239,13 @@ } /* fall through */ default: - LOGPFSML(trxcon_fsm, LOGL_ERROR, + LOGPFSML(trxcon->fi, LOGL_ERROR, "Unhandled L2 DATA.cnf (type 0x%02x)\n", dt); return -ENODEV; } trxcon_gsmtap_send(lchan_desc, fn, lchan->ts->index, - app_data.trx->band_arfcn | ARFCN_UPLINK, + trxcon->trx->band_arfcn | ARFCN_UPLINK, 0, 0, data, data_len); return rc; @@ -255,23 +256,25 @@ uint32_t event, void *data) { if (event == L1CTL_EVENT_CONNECT) - osmo_fsm_inst_state_chg(trxcon_fsm, TRXCON_STATE_MANAGED, 0, 0); + osmo_fsm_inst_state_chg(fi, TRXCON_STATE_MANAGED, 0, 0); } static void trxcon_fsm_managed_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) { + struct trxcon_inst *trxcon = fi->priv; + switch (event) { case L1CTL_EVENT_DISCONNECT: - osmo_fsm_inst_state_chg(trxcon_fsm, TRXCON_STATE_IDLE, 0, 0); + osmo_fsm_inst_state_chg(fi, TRXCON_STATE_IDLE, 0, 0); - if (app_data.trx->fsm->state != TRX_STATE_OFFLINE) { + if (trxcon->trx->fsm->state != TRX_STATE_OFFLINE) { /* Reset scheduler and clock counter */ - l1sched_reset(app_data.sched, true); + l1sched_reset(trxcon->sched, true); /* TODO: implement trx_if_reset() */ - trx_if_cmd_poweroff(app_data.trx); - trx_if_cmd_echo(app_data.trx); + trx_if_cmd_poweroff(trxcon->trx); + trx_if_cmd_echo(trxcon->trx); } break; case TRX_EVENT_RSP_ERROR: @@ -310,13 +313,70 @@ }; static struct osmo_fsm trxcon_fsm_def = { - .name = "trxcon_app_fsm", + .name = "trxcon", .states = trxcon_fsm_states, .num_states = ARRAY_SIZE(trxcon_fsm_states), .log_subsys = DAPP, .event_names = trxcon_fsm_event_names, }; +struct trxcon_inst *trxcon_inst_alloc(void *ctx) +{ + struct trxcon_inst *trxcon; + + trxcon = talloc_zero(ctx, struct trxcon_inst); + OSMO_ASSERT(trxcon != NULL); + + trxcon->fi = osmo_fsm_inst_alloc(&trxcon_fsm_def, tall_trxcon_ctx, + trxcon, LOGL_DEBUG, NULL); + OSMO_ASSERT(trxcon->fi != NULL); + + /* Init L1CTL server */ + trxcon->l1l = l1ctl_link_init(trxcon, app_data.bind_socket); + if (trxcon->l1l == NULL) { + trxcon_inst_free(trxcon); + return NULL; + } + + /* Init transceiver interface */ + trxcon->trx = trx_if_open(trxcon, + app_data.trx_bind_ip, + app_data.trx_remote_ip, + app_data.trx_base_port); + if (trxcon->trx == NULL) { + trxcon_inst_free(trxcon); + return NULL; + } + + trxcon->l1l->priv = trxcon; + trxcon->trx->priv = trxcon; + + /* Init scheduler */ + trxcon->sched = l1sched_alloc(trxcon, app_data.trx_fn_advance, trxcon); + if (trxcon->sched == NULL) { + trxcon_inst_free(trxcon); + return NULL; + } + + return trxcon; +} + +void trxcon_inst_free(struct trxcon_inst *trxcon) +{ + /* Shutdown the scheduler */ + if (trxcon->sched != NULL) + l1sched_free(trxcon->sched); + /* Close active connections */ + if (trxcon->l1l != NULL) + l1ctl_link_shutdown(trxcon->l1l); + if (trxcon->trx != NULL) + trx_if_close(trxcon->trx); + + if (trxcon->fi != NULL) + osmo_fsm_inst_free(trxcon->fi); + talloc_free(trxcon); +} + static void print_usage(const char *app) { printf("Usage: %s\n", app); @@ -427,6 +487,7 @@ int main(int argc, char **argv) { + struct trxcon_inst *trxcon = NULL; int rc = 0; printf("%s", COPYRIGHT); @@ -466,37 +527,14 @@ gsmtap_source_add_sink(app_data.gsmtap); } - /* Allocate the application state machine */ + /* Register the trxcon state machine */ OSMO_ASSERT(osmo_fsm_register(&trxcon_fsm_def) == 0); - trxcon_fsm = osmo_fsm_inst_alloc(&trxcon_fsm_def, tall_trxcon_ctx, - NULL, LOGL_DEBUG, "main"); - /* Init L1CTL server */ - app_data.l1l = l1ctl_link_init(tall_trxcon_ctx, - app_data.bind_socket); - if (app_data.l1l == NULL) + /* Allocate the trxcon instance (only one for now) */ + trxcon = trxcon_inst_alloc(tall_trxcon_ctx); + if (trxcon == NULL) goto exit; - /* Init transceiver interface */ - app_data.trx = trx_if_open(tall_trxcon_ctx, - app_data.trx_bind_ip, app_data.trx_remote_ip, - app_data.trx_base_port); - if (!app_data.trx) - goto exit; - - /* Bind L1CTL with TRX and vice versa */ - app_data.l1l->trx = app_data.trx; - app_data.trx->l1l = app_data.l1l; - - /* Init scheduler */ - app_data.sched = l1sched_alloc(tall_trxcon_ctx, app_data.trx_fn_advance); - if (app_data.sched == NULL) - goto exit; - - /* Let both L1CTL and TRX interfaces access to the scheduler */ - app_data.l1l->sched = app_data.sched; - app_data.trx->sched = app_data.sched; - LOGP(DAPP, LOGL_NOTICE, "Init complete\n"); if (app_data.daemonize) { @@ -514,13 +552,9 @@ osmo_select_main(0); exit: - /* Close active connections */ - l1ctl_link_shutdown(app_data.l1l); - l1sched_free(app_data.sched); - trx_if_close(app_data.trx); - - /* Shutdown main state machine */ - osmo_fsm_inst_free(trxcon_fsm); + /* Release the trxcon instance */ + if (trxcon != NULL) + trxcon_inst_free(trxcon); /* Deinitialize logging */ log_fini(); -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28667
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I23319951c56577085e1092669b5534f9d6bda48d Gerrit-Change-Number: 28667 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmocom-bb[master]: trxcon: rework L1CTL socket API to support multiple clients
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28669
) Change subject: trxcon: rework L1CTL socket API to support multiple clients ...................................................................... trxcon: rework L1CTL socket API to support multiple clients Change-Id: I1cfc49f36ead6e2ba0a6110b0fb65c55412ef5e3 --- M src/host/trxcon/include/osmocom/bb/trxcon/l1ctl.h M src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h M src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h M src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h M src/host/trxcon/src/l1ctl.c M src/host/trxcon/src/l1ctl_link.c M src/host/trxcon/src/trx_if.c M src/host/trxcon/src/trxcon.c 8 files changed, 262 insertions(+), 273 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/69/28669/1 diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl.h b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl.h index 4d1670e..cc8dc84 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl.h @@ -7,21 +7,21 @@ #include <osmocom/bb/trxcon/l1ctl_proto.h> /* Event handlers */ -int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg); +int l1ctl_rx_cb(struct l1ctl_client *client, struct msgb *msg); -int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result, +int l1ctl_tx_fbsb_conf(struct l1ctl_client *l1c, uint8_t result, const struct l1ctl_info_dl *dl_info, uint8_t bsic); -int l1ctl_tx_ccch_mode_conf(struct l1ctl_link *l1l, uint8_t mode); -int l1ctl_tx_pm_conf(struct l1ctl_link *l1l, uint16_t band_arfcn, +int l1ctl_tx_ccch_mode_conf(struct l1ctl_client *l1c, uint8_t mode); +int l1ctl_tx_pm_conf(struct l1ctl_client *l1c, uint16_t band_arfcn, int dbm, int last); -int l1ctl_tx_reset_conf(struct l1ctl_link *l1l, uint8_t type); -int l1ctl_tx_reset_ind(struct l1ctl_link *l1l, uint8_t type); +int l1ctl_tx_reset_conf(struct l1ctl_client *l1c, uint8_t type); +int l1ctl_tx_reset_ind(struct l1ctl_client *l1c, uint8_t type); -int l1ctl_tx_dt_ind(struct l1ctl_link *l1l, +int l1ctl_tx_dt_ind(struct l1ctl_client *l1c, const struct l1ctl_info_dl *dl_info, const uint8_t *l2, size_t l2_len, bool traffic); -int l1ctl_tx_dt_conf(struct l1ctl_link *l1l, +int l1ctl_tx_dt_conf(struct l1ctl_client *l1c, struct l1ctl_info_dl *data, bool traffic); -int l1ctl_tx_rach_conf(struct l1ctl_link *l1l, +int l1ctl_tx_rach_conf(struct l1ctl_client *l1c, uint16_t band_arfcn, uint32_t fn); diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h index 84a8638..fdfc6d9 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_link.h @@ -6,7 +6,6 @@ #include <osmocom/core/select.h> #include <osmocom/core/timer.h> #include <osmocom/core/msgb.h> -#include <osmocom/core/fsm.h> #define L1CTL_LENGTH 256 #define L1CTL_HEADROOM 32 @@ -17,22 +16,38 @@ */ #define L1CTL_MSG_LEN_FIELD 2 -enum l1ctl_fsm_states { - L1CTL_STATE_IDLE = 0, - L1CTL_STATE_CONNECTED, +struct l1ctl_client; + +typedef int l1ctl_conn_data_func(struct l1ctl_client *, struct msgb *); +typedef void l1ctl_conn_state_func(struct l1ctl_client *); + +struct l1ctl_server { + struct llist_head clients; + struct osmo_fd ofd; + void *talloc_ctx; + + l1ctl_conn_data_func *conn_read_cb; /* mandatory */ + l1ctl_conn_state_func *conn_accept_cb; /* optional */ + l1ctl_conn_state_func *conn_close_cb; /* optional */ }; -struct l1ctl_link { - struct osmo_fsm_inst *fsm; - struct osmo_fd listen_bfd; +struct l1ctl_client { + /* List head in l1ctl_server.clients */ + struct llist_head list; + /* Backpointer to l1ctl_server we belong to */ + struct l1ctl_server *server; + /* Write queue */ struct osmo_wqueue wq; - /* Some private data */ void *priv; }; -struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path); -void l1ctl_link_shutdown(struct l1ctl_link *l1l); +int l1ctl_server_start(struct l1ctl_server *server, + const char *sock_path, void *ctx, + l1ctl_conn_data_func *conn_read_cb, + l1ctl_conn_state_func *conn_accept_cb, + l1ctl_conn_state_func *conn_close_cb); +void l1ctl_server_shutdown(struct l1ctl_server *server); -int l1ctl_link_send(struct l1ctl_link *l1l, struct msgb *msg); -int l1ctl_link_close_conn(struct l1ctl_link *l1l); +int l1ctl_client_send(struct l1ctl_client *client, struct msgb *msg); +void l1ctl_client_conn_close(struct l1ctl_client *client); diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h index 26c7829..a295584 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h @@ -51,7 +51,7 @@ int cmd_len; }; -struct trx_instance *trx_if_open(void *tall_ctx, +struct trx_instance *trx_if_open(void *tall_ctx, void *priv, const char *local_host, const char *remote_host, uint16_t port); void trx_if_flush_ctrl(struct trx_instance *trx); void trx_if_close(struct trx_instance *trx); diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h index 986f423..2a068b7 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h @@ -4,7 +4,7 @@ struct l1sched_state; struct trx_instance; -struct l1ctl_link; +struct l1ctl_client; enum trxcon_fsm_states { TRXCON_STATE_IDLE = 0, @@ -28,7 +28,7 @@ struct l1sched_state *sched; /* L1/L2 interfaces */ struct trx_instance *trx; - struct l1ctl_link *l1l; + struct l1ctl_client *l1c; /* TODO: implement this as an FSM state with timeout */ struct osmo_timer_list fbsb_timer; diff --git a/src/host/trxcon/src/l1ctl.c b/src/host/trxcon/src/l1ctl.c index def7414..885ca93 100644 --- a/src/host/trxcon/src/l1ctl.c +++ b/src/host/trxcon/src/l1ctl.c @@ -77,7 +77,7 @@ return msg; } -int l1ctl_tx_pm_conf(struct l1ctl_link *l1l, uint16_t band_arfcn, +int l1ctl_tx_pm_conf(struct l1ctl_client *l1c, uint16_t band_arfcn, int dbm, int last) { struct l1ctl_pm_conf *pmc; @@ -101,10 +101,10 @@ l1h->flags |= L1CTL_F_DONE; } - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } -int l1ctl_tx_reset_ind(struct l1ctl_link *l1l, uint8_t type) +int l1ctl_tx_reset_ind(struct l1ctl_client *l1c, uint8_t type) { struct msgb *msg; struct l1ctl_reset *res; @@ -118,10 +118,10 @@ res = (struct l1ctl_reset *) msgb_put(msg, sizeof(*res)); res->type = type; - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } -int l1ctl_tx_reset_conf(struct l1ctl_link *l1l, uint8_t type) +int l1ctl_tx_reset_conf(struct l1ctl_client *l1c, uint8_t type) { struct msgb *msg; struct l1ctl_reset *res; @@ -134,7 +134,7 @@ res = (struct l1ctl_reset *) msgb_put(msg, sizeof(*res)); res->type = type; - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } static struct l1ctl_info_dl *put_dl_info_hdr(struct msgb *msg, @@ -164,10 +164,10 @@ return conf; } -int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result, +int l1ctl_tx_fbsb_conf(struct l1ctl_client *l1c, uint8_t result, const struct l1ctl_info_dl *dl_info, uint8_t bsic) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_fbsb_conf *conf; struct msgb *msg; @@ -189,10 +189,10 @@ if (osmo_timer_pending(&trxcon->fbsb_timer)) osmo_timer_del(&trxcon->fbsb_timer); - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } -int l1ctl_tx_ccch_mode_conf(struct l1ctl_link *l1l, uint8_t mode) +int l1ctl_tx_ccch_mode_conf(struct l1ctl_client *l1c, uint8_t mode) { struct l1ctl_ccch_mode_conf *conf; struct msgb *msg; @@ -204,13 +204,13 @@ conf = (struct l1ctl_ccch_mode_conf *) msgb_put(msg, sizeof(*conf)); conf->ccch_mode = mode; - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } /** * Handles both L1CTL_DATA_IND and L1CTL_TRAFFIC_IND. */ -int l1ctl_tx_dt_ind(struct l1ctl_link *l1l, +int l1ctl_tx_dt_ind(struct l1ctl_client *l1c, const struct l1ctl_info_dl *dl_info, const uint8_t *l2, size_t l2_len, bool traffic) @@ -232,10 +232,10 @@ } /* Put message to upper layers */ - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } -int l1ctl_tx_rach_conf(struct l1ctl_link *l1l, +int l1ctl_tx_rach_conf(struct l1ctl_client *l1c, uint16_t band_arfcn, uint32_t fn) { struct l1ctl_info_dl *dl; @@ -251,14 +251,14 @@ dl->band_arfcn = htons(band_arfcn); dl->frame_nr = htonl(fn); - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } /** * Handles both L1CTL_DATA_CONF and L1CTL_TRAFFIC_CONF. */ -int l1ctl_tx_dt_conf(struct l1ctl_link *l1l, +int l1ctl_tx_dt_conf(struct l1ctl_client *l1c, struct l1ctl_info_dl *data, bool traffic) { struct msgb *msg; @@ -271,7 +271,7 @@ /* Copy DL frame header from source message */ put_dl_info_hdr(msg, data); - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } static enum gsm_phys_chan_config l1ctl_ccch_mode2pchan_config(enum ccch_mode mode) @@ -297,8 +297,8 @@ /* FBSB expire timer */ static void fbsb_timer_cb(void *data) { - struct l1ctl_link *l1l = (struct l1ctl_link *) data; - struct trxcon_inst *trxcon = l1l->priv; + struct l1ctl_client *l1c = (struct l1ctl_client *) data; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_info_dl *dl; struct msgb *msg; @@ -319,12 +319,12 @@ /* Ask SCH handler not to send L1CTL_FBSB_CONF anymore */ trxcon->fbsb_conf_sent = true; - l1ctl_link_send(l1l, msg); + l1ctl_client_send(l1c, msg); } -static int l1ctl_rx_fbsb_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_fbsb_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; enum gsm_phys_chan_config ch_config; struct l1ctl_fbsb_req *fbsb; uint16_t band_arfcn; @@ -372,7 +372,7 @@ trx_if_cmd_poweron(trxcon->trx); /* Start FBSB expire timer */ - trxcon->fbsb_timer.data = l1l; + trxcon->fbsb_timer.data = l1c; trxcon->fbsb_timer.cb = fbsb_timer_cb; LOGP(DL1C, LOGL_INFO, "Starting FBSB timer %u ms\n", timeout * GSM_TDMA_FN_DURATION_uS / 1000); osmo_timer_schedule(&trxcon->fbsb_timer, 0, @@ -383,10 +383,10 @@ return rc; } -static int l1ctl_rx_pm_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_pm_req(struct l1ctl_client *l1c, struct msgb *msg) { uint16_t band_arfcn_start, band_arfcn_stop; - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_pm_req *pmr; int rc = 0; @@ -415,9 +415,9 @@ return rc; } -static int l1ctl_rx_reset_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_reset_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_reset *res; int rc = 0; @@ -448,14 +448,14 @@ } /* Confirm */ - rc = l1ctl_tx_reset_conf(l1l, res->type); + rc = l1ctl_tx_reset_conf(l1c, res->type); exit: msgb_free(msg); return rc; } -static int l1ctl_rx_echo_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_echo_req(struct l1ctl_client *l1c, struct msgb *msg) { struct l1ctl_hdr *l1h; @@ -467,12 +467,12 @@ l1h->msg_type = L1CTL_ECHO_CONF; msg->data = msg->l1h; - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } -static int l1ctl_rx_ccch_mode_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_ccch_mode_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; enum gsm_phys_chan_config ch_config; struct l1ctl_ccch_mode_req *req; struct l1sched_ts *ts; @@ -506,16 +506,16 @@ /* Confirm reconfiguration */ if (!rc) - rc = l1ctl_tx_ccch_mode_conf(l1l, req->ccch_mode); + rc = l1ctl_tx_ccch_mode_conf(l1c, req->ccch_mode); exit: msgb_free(msg); return rc; } -static int l1ctl_rx_rach_req(struct l1ctl_link *l1l, struct msgb *msg, bool ext) +static int l1ctl_rx_rach_req(struct l1ctl_client *l1c, struct msgb *msg, bool ext) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_info_ul *ul; struct l1sched_ts_prim *prim; struct l1sched_ts_prim_rach rach; @@ -631,9 +631,9 @@ return 0; } -static int l1ctl_rx_dm_est_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_dm_est_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; enum gsm_phys_chan_config config; struct l1ctl_dm_est_req *est_req; struct l1ctl_info_ul *ul; @@ -691,9 +691,9 @@ return rc; } -static int l1ctl_rx_dm_rel_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_dm_rel_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; LOGP(DL1C, LOGL_NOTICE, "Received L1CTL_DM_REL_REQ, resetting scheduler\n"); @@ -707,10 +707,10 @@ /** * Handles both L1CTL_DATA_REQ and L1CTL_TRAFFIC_REQ. */ -static int l1ctl_rx_dt_req(struct l1ctl_link *l1l, +static int l1ctl_rx_dt_req(struct l1ctl_client *l1c, struct msgb *msg, bool traffic) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_info_ul *ul; struct l1sched_ts_prim *prim; uint8_t chan_nr, link_id; @@ -742,9 +742,9 @@ return rc; } -static int l1ctl_rx_param_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_param_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_par_req *par_req; struct l1ctl_info_ul *ul; @@ -766,9 +766,9 @@ return 0; } -static int l1ctl_rx_tch_mode_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_tch_mode_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_tch_mode_req *req; struct l1sched_lchan_state *lchan; struct l1sched_ts *ts; @@ -807,12 +807,12 @@ struct l1ctl_hdr *l1h = (struct l1ctl_hdr *) msg->data; l1h->msg_type = L1CTL_TCH_MODE_CONF; - return l1ctl_link_send(l1l, msg); + return l1ctl_client_send(l1c, msg); } -static int l1ctl_rx_crypto_req(struct l1ctl_link *l1l, struct msgb *msg) +static int l1ctl_rx_crypto_req(struct l1ctl_client *l1c, struct msgb *msg) { - struct trxcon_inst *trxcon = l1l->priv; + struct trxcon_inst *trxcon = l1c->priv; struct l1ctl_crypto_req *req; struct l1ctl_info_ul *ul; struct l1sched_ts *ts; @@ -849,7 +849,7 @@ return rc; } -int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg) +int l1ctl_rx_cb(struct l1ctl_client *l1c, struct msgb *msg) { struct l1ctl_hdr *l1h; @@ -858,33 +858,33 @@ switch (l1h->msg_type) { case L1CTL_FBSB_REQ: - return l1ctl_rx_fbsb_req(l1l, msg); + return l1ctl_rx_fbsb_req(l1c, msg); case L1CTL_PM_REQ: - return l1ctl_rx_pm_req(l1l, msg); + return l1ctl_rx_pm_req(l1c, msg); case L1CTL_RESET_REQ: - return l1ctl_rx_reset_req(l1l, msg); + return l1ctl_rx_reset_req(l1c, msg); case L1CTL_ECHO_REQ: - return l1ctl_rx_echo_req(l1l, msg); + return l1ctl_rx_echo_req(l1c, msg); case L1CTL_CCCH_MODE_REQ: - return l1ctl_rx_ccch_mode_req(l1l, msg); + return l1ctl_rx_ccch_mode_req(l1c, msg); case L1CTL_RACH_REQ: - return l1ctl_rx_rach_req(l1l, msg, false); + return l1ctl_rx_rach_req(l1c, msg, false); case L1CTL_EXT_RACH_REQ: - return l1ctl_rx_rach_req(l1l, msg, true); + return l1ctl_rx_rach_req(l1c, msg, true); case L1CTL_DM_EST_REQ: - return l1ctl_rx_dm_est_req(l1l, msg); + return l1ctl_rx_dm_est_req(l1c, msg); case L1CTL_DM_REL_REQ: - return l1ctl_rx_dm_rel_req(l1l, msg); + return l1ctl_rx_dm_rel_req(l1c, msg); case L1CTL_DATA_REQ: - return l1ctl_rx_dt_req(l1l, msg, false); + return l1ctl_rx_dt_req(l1c, msg, false); case L1CTL_TRAFFIC_REQ: - return l1ctl_rx_dt_req(l1l, msg, true); + return l1ctl_rx_dt_req(l1c, msg, true); case L1CTL_PARAM_REQ: - return l1ctl_rx_param_req(l1l, msg); + return l1ctl_rx_param_req(l1c, msg); case L1CTL_TCH_MODE_REQ: - return l1ctl_rx_tch_mode_req(l1l, msg); + return l1ctl_rx_tch_mode_req(l1c, msg); case L1CTL_CRYPTO_REQ: - return l1ctl_rx_crypto_req(l1l, msg); + return l1ctl_rx_crypto_req(l1c, msg); /* Not (yet) handled messages */ case L1CTL_NEIGH_PM_REQ: diff --git a/src/host/trxcon/src/l1ctl_link.c b/src/host/trxcon/src/l1ctl_link.c index 672991c..a9d5b1f 100644 --- a/src/host/trxcon/src/l1ctl_link.c +++ b/src/host/trxcon/src/l1ctl_link.c @@ -1,9 +1,10 @@ /* * OsmocomBB <-> SDR connection bridge - * GSM L1 control socket (/tmp/osmocom_l2) handlers + * Abstract UNIX socket server * * (C) 2013 by Sylvain Munaut <tnt(a)246tNt.com> * (C) 2016-2017 by Vadim Yanitskiy <axilirator(a)gmail.com> + * (C) 2022 by by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> * * All Rights Reserved * @@ -24,60 +25,33 @@ #include <unistd.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include <sys/un.h> #include <arpa/inet.h> #include <sys/socket.h> -#include <osmocom/core/fsm.h> #include <osmocom/core/talloc.h> #include <osmocom/core/select.h> #include <osmocom/core/socket.h> #include <osmocom/core/write_queue.h> -#include <osmocom/bb/trxcon/trxcon.h> #include <osmocom/bb/trxcon/logging.h> #include <osmocom/bb/trxcon/l1ctl_link.h> -#include <osmocom/bb/trxcon/l1ctl.h> -static struct value_string l1ctl_evt_names[] = { - { 0, NULL } /* no events? */ -}; - -static struct osmo_fsm_state l1ctl_fsm_states[] = { - [L1CTL_STATE_IDLE] = { - .out_state_mask = GEN_MASK(L1CTL_STATE_CONNECTED), - .name = "IDLE", - }, - [L1CTL_STATE_CONNECTED] = { - .out_state_mask = GEN_MASK(L1CTL_STATE_IDLE), - .name = "CONNECTED", - }, -}; - -static struct osmo_fsm l1ctl_fsm = { - .name = "l1ctl_link_fsm", - .states = l1ctl_fsm_states, - .num_states = ARRAY_SIZE(l1ctl_fsm_states), - .log_subsys = DL1C, - .event_names = l1ctl_evt_names, -}; - -static int l1ctl_link_read_cb(struct osmo_fd *bfd) +static int l1ctl_client_read_cb(struct osmo_fd *ofd) { - struct l1ctl_link *l1l = (struct l1ctl_link *) bfd->data; + struct l1ctl_client *client = (struct l1ctl_client *)ofd->data; struct msgb *msg; uint16_t len; int rc; /* Attempt to read from socket */ - rc = read(bfd->fd, &len, L1CTL_MSG_LEN_FIELD); + rc = read(ofd->fd, &len, L1CTL_MSG_LEN_FIELD); if (rc < L1CTL_MSG_LEN_FIELD) { - LOGP(DL1D, LOGL_NOTICE, "L1CTL has lost connection\n"); + LOGP(DL1D, LOGL_NOTICE, "L1CTL server has lost connection\n"); if (rc >= 0) rc = -EIO; - l1ctl_link_close_conn(l1l); + l1ctl_client_conn_close(client); return rc; } @@ -97,7 +71,7 @@ } msg->l1h = msgb_put(msg, len); - rc = read(bfd->fd, msg->l1h, msgb_l1len(msg)); + rc = read(ofd->fd, msg->l1h, msgb_l1len(msg)); if (rc != len) { LOGP(DL1D, LOGL_ERROR, "Can not read data: len=%d < rc=%d: " "%s\n", len, rc, strerror(errno)); @@ -110,19 +84,19 @@ osmo_hexdump(msg->data, msg->len)); /* Call L1CTL handler */ - l1ctl_rx_cb(l1l, msg); + client->server->conn_read_cb(client, msg); return 0; } -static int l1ctl_link_write_cb(struct osmo_fd *bfd, struct msgb *msg) +static int l1ctl_client_write_cb(struct osmo_fd *ofd, struct msgb *msg) { int len; - if (bfd->fd <= 0) + if (ofd->fd <= 0) return -EINVAL; - len = write(bfd->fd, msg->data, msg->len); + len = write(ofd->fd, msg->data, msg->len); if (len != msg->len) { LOGP(DL1D, LOGL_ERROR, "Failed to write data: " "written (%d) < msg_len (%d)\n", len, msg->len); @@ -133,53 +107,63 @@ } /* Connection handler */ -static int l1ctl_link_accept(struct osmo_fd *bfd, unsigned int flags) +static int l1ctl_client_conn_accept(struct osmo_fd *sfd, unsigned int flags) { - struct l1ctl_link *l1l = (struct l1ctl_link *) bfd->data; - struct trxcon_inst *trxcon = l1l->priv; - struct osmo_fd *conn_bfd = &l1l->wq.bfd; - struct sockaddr_un un_addr; - socklen_t len; - int cfd; + struct l1ctl_server *server = (struct l1ctl_server *)sfd->data; + struct l1ctl_client *client; + int rc, client_fd; - len = sizeof(un_addr); - cfd = accept(bfd->fd, (struct sockaddr *) &un_addr, &len); - if (cfd < 0) { - LOGP(DL1C, LOGL_ERROR, "Failed to accept a new connection\n"); - return -1; + client_fd = accept(sfd->fd, NULL, NULL); + if (client_fd < 0) { + LOGP(DL1C, LOGL_ERROR, "Failed to accept() a new connection: " + "%s\n", strerror(errno)); + return client_fd; } - /* Check if we already have an active connection */ - if (conn_bfd->fd != -1) { - LOGP(DL1C, LOGL_NOTICE, "A new connection rejected: " - "we already have another active\n"); - close(cfd); - return 0; + /* TODO: remove this barrier when multi-trxcon support is implemented */ + if (!llist_empty(&server->clients)) { + LOGP(DL1C, LOGL_NOTICE, "L1CTL client rejected: " + "we already have an active connection\n"); + close(client_fd); + return -ENOMEM; } - osmo_wqueue_init(&l1l->wq, 100); - INIT_LLIST_HEAD(&conn_bfd->list); - - l1l->wq.write_cb = l1ctl_link_write_cb; - l1l->wq.read_cb = l1ctl_link_read_cb; - osmo_fd_setup(conn_bfd, cfd, OSMO_FD_READ, osmo_wqueue_bfd_cb, l1l, 0); - - if (osmo_fd_register(conn_bfd) != 0) { - LOGP(DL1C, LOGL_ERROR, "Failed to register new connection fd\n"); - close(conn_bfd->fd); - conn_bfd->fd = -1; - return -1; + client = talloc_zero(server->talloc_ctx, struct l1ctl_client); + if (client == NULL) { + LOGP(DL1C, LOGL_ERROR, "Failed to allocate an L1CTL client\n"); + close(client_fd); + return -ENOMEM; } - osmo_fsm_inst_dispatch(trxcon->fi, L1CTL_EVENT_CONNECT, l1l); - osmo_fsm_inst_state_chg(l1l->fsm, L1CTL_STATE_CONNECTED, 0, 0); + /* Init the client's write queue */ + osmo_wqueue_init(&client->wq, 100); + INIT_LLIST_HEAD(&client->wq.bfd.list); - LOGP(DL1C, LOGL_NOTICE, "L1CTL has a new connection\n"); + client->wq.write_cb = &l1ctl_client_write_cb; + client->wq.read_cb = &l1ctl_client_read_cb; + osmo_fd_setup(&client->wq.bfd, client_fd, OSMO_FD_READ, &osmo_wqueue_bfd_cb, client, 0); + + /* Register the client's write queue */ + rc = osmo_fd_register(&client->wq.bfd); + if (rc != 0) { + LOGP(DL1C, LOGL_ERROR, "Failed to register a new connection fd\n"); + close(client->wq.bfd.fd); + talloc_free(client); + return rc; + } + + LOGP(DL1C, LOGL_NOTICE, "L1CTL server got a new connection\n"); + + llist_add_tail(&client->list, &server->clients); + client->server = server; + + if (client->server->conn_accept_cb != NULL) + client->server->conn_accept_cb(client); return 0; } -int l1ctl_link_send(struct l1ctl_link *l1l, struct msgb *msg) +int l1ctl_client_send(struct l1ctl_client *client, struct msgb *msg) { uint8_t *len; @@ -194,7 +178,7 @@ len = msgb_push(msg, L1CTL_MSG_LEN_FIELD); osmo_store16be(msg->len - L1CTL_MSG_LEN_FIELD, len); - if (osmo_wqueue_enqueue(&l1l->wq, msg) != 0) { + if (osmo_wqueue_enqueue(&client->wq, msg) != 0) { LOGP(DL1D, LOGL_ERROR, "Failed to enqueue msg!\n"); msgb_free(msg); return -EIO; @@ -203,105 +187,74 @@ return 0; } -int l1ctl_link_close_conn(struct l1ctl_link *l1l) +void l1ctl_client_conn_close(struct l1ctl_client *client) { - struct osmo_fd *conn_bfd = &l1l->wq.bfd; - struct trxcon_inst *trxcon = l1l->priv; - - if (conn_bfd->fd <= 0) - return -EINVAL; + if (client->server->conn_close_cb != NULL) + client->server->conn_close_cb(client); /* Close connection socket */ - osmo_fd_unregister(conn_bfd); - close(conn_bfd->fd); - conn_bfd->fd = -1; + osmo_fd_unregister(&client->wq.bfd); + close(client->wq.bfd.fd); + client->wq.bfd.fd = -1; /* Clear pending messages */ - osmo_wqueue_clear(&l1l->wq); + osmo_wqueue_clear(&client->wq); - osmo_fsm_inst_dispatch(trxcon->fi, L1CTL_EVENT_DISCONNECT, l1l); - osmo_fsm_inst_state_chg(l1l->fsm, L1CTL_STATE_IDLE, 0, 0); + llist_del(&client->list); + talloc_free(client); +} + +int l1ctl_server_start(struct l1ctl_server *server, + const char *sock_path, void *ctx, + l1ctl_conn_data_func *conn_read_cb, + l1ctl_conn_state_func *conn_accept_cb, + l1ctl_conn_state_func *conn_close_cb) +{ + int rc; + + LOGP(DL1C, LOGL_NOTICE, "Init L1CTL server (sock_path=%s)\n", sock_path); + + *server = (struct l1ctl_server) { + .clients = LLIST_HEAD_INIT(server->clients), + .conn_accept_cb = conn_accept_cb, + .conn_close_cb = conn_close_cb, + .conn_read_cb = conn_read_cb, + .talloc_ctx = ctx, + }; + + /* conn_read_cb shall not be NULL */ + OSMO_ASSERT(conn_read_cb != NULL); + + /* Bind connection handler */ + osmo_fd_setup(&server->ofd, -1, OSMO_FD_READ, &l1ctl_client_conn_accept, server, 0); + + rc = osmo_sock_unix_init_ofd(&server->ofd, SOCK_STREAM, 0, sock_path, OSMO_SOCK_F_BIND); + if (rc < 0) { + LOGP(DL1C, LOGL_ERROR, "Could not create UNIX socket: %s\n", + strerror(errno)); + talloc_free(server); + return rc; + } return 0; } -struct l1ctl_link *l1ctl_link_init(void *tall_ctx, const char *sock_path) +void l1ctl_server_shutdown(struct l1ctl_server *server) { - struct l1ctl_link *l1l; - struct osmo_fd *bfd; - int rc; + LOGP(DL1C, LOGL_NOTICE, "Shutdown L1CTL server\n"); - LOGP(DL1C, LOGL_NOTICE, "Init L1CTL link (%s)\n", sock_path); - - l1l = talloc_zero(tall_ctx, struct l1ctl_link); - if (!l1l) { - LOGP(DL1C, LOGL_ERROR, "Failed to allocate memory\n"); - return NULL; + /* Close all client connections */ + while (!llist_empty(&server->clients)) { + struct l1ctl_client *client = llist_entry(server->clients.next, + struct l1ctl_client, + list); + l1ctl_client_conn_close(client); } - /* Allocate a new dedicated state machine */ - l1l->fsm = osmo_fsm_inst_alloc(&l1ctl_fsm, l1l, - NULL, LOGL_DEBUG, "l1ctl_link"); - if (l1l->fsm == NULL) { - LOGP(DTRX, LOGL_ERROR, "Failed to allocate an instance " - "of FSM '%s'\n", l1ctl_fsm.name); - talloc_free(l1l); - return NULL; - } - - /* Create a socket and bind handlers */ - bfd = &l1l->listen_bfd; - - /* Bind connection handler */ - osmo_fd_setup(bfd, -1, OSMO_FD_READ, l1ctl_link_accept, l1l, 0); - - rc = osmo_sock_unix_init_ofd(bfd, SOCK_STREAM, 0, sock_path, - OSMO_SOCK_F_BIND); - if (rc < 0) { - LOGP(DL1C, LOGL_ERROR, "Could not create UNIX socket: %s\n", - strerror(errno)); - osmo_fsm_inst_free(l1l->fsm); - talloc_free(l1l); - return NULL; - } - - /** - * To be able to accept first connection and - * drop others, it should be set to -1 - */ - l1l->wq.bfd.fd = -1; - - return l1l; -} - -void l1ctl_link_shutdown(struct l1ctl_link *l1l) -{ - struct osmo_fd *listen_bfd; - - /* May be unallocated due to init error */ - if (!l1l) - return; - - LOGP(DL1C, LOGL_NOTICE, "Shutdown L1CTL link\n"); - - listen_bfd = &l1l->listen_bfd; - - /* Check if we have an established connection */ - if (l1l->wq.bfd.fd != -1) - l1ctl_link_close_conn(l1l); - /* Unbind listening socket */ - if (listen_bfd->fd != -1) { - osmo_fd_unregister(listen_bfd); - close(listen_bfd->fd); - listen_bfd->fd = -1; + if (server->ofd.fd != -1) { + osmo_fd_unregister(&server->ofd); + close(server->ofd.fd); + server->ofd.fd = -1; } - - osmo_fsm_inst_free(l1l->fsm); - talloc_free(l1l); -} - -static __attribute__((constructor)) void on_dso_load(void) -{ - OSMO_ASSERT(osmo_fsm_register(&l1ctl_fsm) == 0); } diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c index 34d8874..8c58da5 100644 --- a/src/host/trxcon/src/trx_if.c +++ b/src/host/trxcon/src/trx_if.c @@ -387,7 +387,7 @@ } /* Send L1CTL_PM_CONF */ - l1ctl_tx_pm_conf(trxcon->l1l, band_arfcn, dbm, + l1ctl_tx_pm_conf(trxcon->l1c, band_arfcn, dbm, band_arfcn == trx->pm_band_arfcn_stop); /* Schedule a next measurement */ @@ -690,7 +690,7 @@ } /* Init TRX interface (TRXC, TRXD sockets and FSM) */ -struct trx_instance *trx_if_open(void *tall_ctx, +struct trx_instance *trx_if_open(void *tall_ctx, void *priv, const char *local_host, const char *remote_host, uint16_t base_port) { @@ -731,6 +731,8 @@ if (rc < 0) goto udp_error; + trx->priv = priv; + return trx; udp_error: diff --git a/src/host/trxcon/src/trxcon.c b/src/host/trxcon/src/trxcon.c index 60d8cf0..1e7ebaa 100644 --- a/src/host/trxcon/src/trxcon.c +++ b/src/host/trxcon/src/trxcon.c @@ -157,16 +157,16 @@ switch (dt) { case L1SCHED_DT_TRAFFIC: case L1SCHED_DT_PACKET_DATA: - rc = l1ctl_tx_dt_ind(trxcon->l1l, &dl_hdr, data, data_len, true); + rc = l1ctl_tx_dt_ind(trxcon->l1c, &dl_hdr, data, data_len, true); break; case L1SCHED_DT_SIGNALING: - rc = l1ctl_tx_dt_ind(trxcon->l1l, &dl_hdr, data, data_len, false); + rc = l1ctl_tx_dt_ind(trxcon->l1c, &dl_hdr, data, data_len, false); break; case L1SCHED_DT_OTHER: if (lchan->type == L1SCHED_SCH) { if (trxcon->fbsb_conf_sent) return 0; - rc = l1ctl_tx_fbsb_conf(trxcon->l1l, 0, &dl_hdr, sched->bsic); + rc = l1ctl_tx_fbsb_conf(trxcon->l1c, 0, &dl_hdr, sched->bsic); break; } /* fall through */ @@ -209,12 +209,12 @@ switch (dt) { case L1SCHED_DT_TRAFFIC: case L1SCHED_DT_PACKET_DATA: - rc = l1ctl_tx_dt_conf(trxcon->l1l, &dl_hdr, true); + rc = l1ctl_tx_dt_conf(trxcon->l1c, &dl_hdr, true); data_len = lchan->prim->payload_len; data = lchan->prim->payload; break; case L1SCHED_DT_SIGNALING: - rc = l1ctl_tx_dt_conf(trxcon->l1l, &dl_hdr, false); + rc = l1ctl_tx_dt_conf(trxcon->l1c, &dl_hdr, false); data_len = lchan->prim->payload_len; data = lchan->prim->payload; break; @@ -224,7 +224,7 @@ rach = (struct l1sched_ts_prim_rach *)lchan->prim->payload; - rc = l1ctl_tx_rach_conf(trxcon->l1l, trxcon->trx->band_arfcn, fn); + rc = l1ctl_tx_rach_conf(trxcon->l1c, trxcon->trx->band_arfcn, fn); if (lchan->prim->type == L1SCHED_PRIM_RACH11) { ra_buf[0] = (uint8_t)(rach->ra >> 3); ra_buf[1] = (uint8_t)(rach->ra & 0x07); @@ -331,15 +331,8 @@ trxcon, LOGL_DEBUG, NULL); OSMO_ASSERT(trxcon->fi != NULL); - /* Init L1CTL server */ - trxcon->l1l = l1ctl_link_init(trxcon, app_data.bind_socket); - if (trxcon->l1l == NULL) { - trxcon_inst_free(trxcon); - return NULL; - } - /* Init transceiver interface */ - trxcon->trx = trx_if_open(trxcon, + trxcon->trx = trx_if_open(trxcon, trxcon, app_data.trx_bind_ip, app_data.trx_remote_ip, app_data.trx_base_port); @@ -348,9 +341,6 @@ return NULL; } - trxcon->l1l->priv = trxcon; - trxcon->trx->priv = trxcon; - /* Init scheduler */ trxcon->sched = l1sched_alloc(trxcon, app_data.trx_fn_advance, trxcon); if (trxcon->sched == NULL) { @@ -367,8 +357,8 @@ if (trxcon->sched != NULL) l1sched_free(trxcon->sched); /* Close active connections */ - if (trxcon->l1l != NULL) - l1ctl_link_shutdown(trxcon->l1l); + if (trxcon->l1c != NULL) + l1ctl_client_conn_close(trxcon->l1c); if (trxcon->trx != NULL) trx_if_close(trxcon->trx); @@ -380,6 +370,32 @@ talloc_free(trxcon); } +static void l1ctl_conn_accept_cb(struct l1ctl_client *l1c) +{ + struct trxcon_inst *trxcon; + + trxcon = trxcon_inst_alloc(l1c); + if (trxcon == NULL) { + l1ctl_client_conn_close(l1c); + return; + } + + l1c->priv = trxcon; + trxcon->l1c = l1c; +} + +static void l1ctl_conn_close_cb(struct l1ctl_client *l1c) +{ + struct trxcon_inst *trxcon = l1c->priv; + + if (trxcon == NULL) + return; + + /* l1c is free()ed by the caller */ + trxcon->l1c = NULL; + trxcon_inst_free(trxcon); +} + static void print_usage(const char *app) { printf("Usage: %s\n", app); @@ -490,7 +506,7 @@ int main(int argc, char **argv) { - struct trxcon_inst *trxcon = NULL; + struct l1ctl_server server; int rc = 0; printf("%s", COPYRIGHT); @@ -533,10 +549,15 @@ /* Register the trxcon state machine */ OSMO_ASSERT(osmo_fsm_register(&trxcon_fsm_def) == 0); - /* Allocate the trxcon instance (only one for now) */ - trxcon = trxcon_inst_alloc(tall_trxcon_ctx); - if (trxcon == NULL) + /* Start the L1CTL server */ + rc = l1ctl_server_start(&server, app_data.bind_socket, + tall_trxcon_ctx, &l1ctl_rx_cb, + &l1ctl_conn_accept_cb, + &l1ctl_conn_close_cb); + if (rc) { + rc = EXIT_FAILURE; goto exit; + } LOGP(DAPP, LOGL_NOTICE, "Init complete\n"); @@ -555,9 +576,7 @@ osmo_select_main(0); exit: - /* Release the trxcon instance */ - if (trxcon != NULL) - trxcon_inst_free(trxcon); + l1ctl_server_shutdown(&server); /* Deinitialize logging */ log_fini(); -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28669
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I1cfc49f36ead6e2ba0a6110b0fb65c55412ef5e3 Gerrit-Change-Number: 28669 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmocom-bb[master]: trxcon: cosmetic: use ARRAY_SIZE() whenever appropriate
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28664
) Change subject: trxcon: cosmetic: use ARRAY_SIZE() whenever appropriate ...................................................................... trxcon: cosmetic: use ARRAY_SIZE() whenever appropriate Change-Id: I2a246bad8d11ed45fbf849de961713ab96907d83 --- M src/host/trxcon/src/l1ctl.c M src/host/trxcon/src/sched_trx.c 2 files changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/64/28664/1 diff --git a/src/host/trxcon/src/l1ctl.c b/src/host/trxcon/src/l1ctl.c index fb8a203..ef88cd9 100644 --- a/src/host/trxcon/src/l1ctl.c +++ b/src/host/trxcon/src/l1ctl.c @@ -765,7 +765,7 @@ "(tch_mode=%u, audio_mode=%u)\n", req->tch_mode, req->audio_mode); /* Iterate over timeslot list */ - for (i = 0; i < TRX_TS_COUNT; i++) { + for (i = 0; i < ARRAY_SIZE(l1l->sched->ts); i++) { /* Timeslot is not allocated */ ts = l1l->sched->ts[i]; if (ts == NULL) diff --git a/src/host/trxcon/src/sched_trx.c b/src/host/trxcon/src/sched_trx.c index 556ebcc..964c72f 100644 --- a/src/host/trxcon/src/sched_trx.c +++ b/src/host/trxcon/src/sched_trx.c @@ -69,7 +69,7 @@ sched->fn_counter_advance); /* Iterate over timeslot list */ - for (i = 0; i < TRX_TS_COUNT; i++) { + for (i = 0; i < ARRAY_SIZE(br); i++) { /* Initialize the buffer for this timeslot */ br[i] = (struct l1sched_burst_req) { .fn = fn, @@ -179,7 +179,7 @@ LOGP(DSCH, LOGL_NOTICE, "Shutdown scheduler\n"); /* Free all potentially allocated timeslots */ - for (i = 0; i < TRX_TS_COUNT; i++) + for (i = 0; i < ARRAY_SIZE(sched->ts); i++) l1sched_del_ts(sched, i); l1sched_clck_reset(sched); @@ -197,7 +197,7 @@ reset_clock ? "and clock counter" : ""); /* Free all potentially allocated timeslots */ - for (i = 0; i < TRX_TS_COUNT; i++) + for (i = 0; i < ARRAY_SIZE(sched->ts); i++) l1sched_del_ts(sched, i); /* Stop and reset clock counter if required */ -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28664
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I2a246bad8d11ed45fbf849de961713ab96907d83 Gerrit-Change-Number: 28664 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmocom-bb[master]: trxcon: cosmetic: use 'unsigned int tn' for timeslot number
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28665
) Change subject: trxcon: cosmetic: use 'unsigned int tn' for timeslot number ...................................................................... trxcon: cosmetic: use 'unsigned int tn' for timeslot number Change-Id: I93b5a91341e7f79ced0591e13250632ba5e5adef --- M src/host/trxcon/src/l1ctl.c M src/host/trxcon/src/sched_trx.c 2 files changed, 19 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/65/28665/1 diff --git a/src/host/trxcon/src/l1ctl.c b/src/host/trxcon/src/l1ctl.c index ef88cd9..5db9945 100644 --- a/src/host/trxcon/src/l1ctl.c +++ b/src/host/trxcon/src/l1ctl.c @@ -757,7 +757,7 @@ struct l1ctl_tch_mode_req *req; struct l1sched_lchan_state *lchan; struct l1sched_ts *ts; - int i; + unsigned int tn; req = (struct l1ctl_tch_mode_req *) msg->l1h; @@ -765,9 +765,9 @@ "(tch_mode=%u, audio_mode=%u)\n", req->tch_mode, req->audio_mode); /* Iterate over timeslot list */ - for (i = 0; i < ARRAY_SIZE(l1l->sched->ts); i++) { + for (tn = 0; tn < ARRAY_SIZE(l1l->sched->ts); tn++) { /* Timeslot is not allocated */ - ts = l1l->sched->ts[i]; + ts = l1l->sched->ts[tn]; if (ts == NULL) continue; diff --git a/src/host/trxcon/src/sched_trx.c b/src/host/trxcon/src/sched_trx.c index 964c72f..d3a0a54 100644 --- a/src/host/trxcon/src/sched_trx.c +++ b/src/host/trxcon/src/sched_trx.c @@ -61,7 +61,7 @@ enum l1sched_lchan_type chan; uint8_t offset; struct l1sched_ts *ts; - int i; + unsigned int tn; /* Advance TDMA frame number in order to give the transceiver * more time to handle the burst before the actual transmission. */ @@ -69,16 +69,16 @@ sched->fn_counter_advance); /* Iterate over timeslot list */ - for (i = 0; i < ARRAY_SIZE(br); i++) { + for (tn = 0; tn < ARRAY_SIZE(br); tn++) { /* Initialize the buffer for this timeslot */ - br[i] = (struct l1sched_burst_req) { + br[tn] = (struct l1sched_burst_req) { .fn = fn, - .tn = i, + .tn = tn, .burst_len = 0, /* NOPE.ind */ }; /* Timeslot is not allocated */ - ts = sched->ts[i]; + ts = sched->ts[tn]; if (ts == NULL) continue; @@ -91,7 +91,7 @@ frame = ts->mf_layout->frames + offset; /* Get required info from frame */ - br[i].bid = frame->ul_bid; + br[tn].bid = frame->ul_bid; chan = frame->ul_chan; handler = l1sched_lchan_desc[chan].tx_fn; @@ -138,16 +138,16 @@ handler = l1sched_lchan_desc[L1SCHED_RACH].tx_fn; /* Poke lchan handler */ - handler(lchan, &br[i]); + handler(lchan, &br[tn]); /* Perform A5/X burst encryption if required */ if (lchan->a5.algo) - l1sched_a5_burst_enc(lchan, &br[i]); + l1sched_a5_burst_enc(lchan, &br[tn]); } /* Send all bursts for this TDMA frame */ - for (i = 0; i < ARRAY_SIZE(br); i++) - l1sched_handle_burst_req(sched, &br[i]); + for (tn = 0; tn < ARRAY_SIZE(br); tn++) + l1sched_handle_burst_req(sched, &br[tn]); } struct l1sched_state *l1sched_alloc(void *ctx, uint32_t fn_advance) @@ -171,7 +171,7 @@ void l1sched_free(struct l1sched_state *sched) { - int i; + unsigned int tn; if (sched == NULL) return; @@ -179,8 +179,8 @@ LOGP(DSCH, LOGL_NOTICE, "Shutdown scheduler\n"); /* Free all potentially allocated timeslots */ - for (i = 0; i < ARRAY_SIZE(sched->ts); i++) - l1sched_del_ts(sched, i); + for (tn = 0; tn < ARRAY_SIZE(sched->ts); tn++) + l1sched_del_ts(sched, tn); l1sched_clck_reset(sched); talloc_free(sched); @@ -188,7 +188,7 @@ void l1sched_reset(struct l1sched_state *sched, bool reset_clock) { - int i; + unsigned int tn; if (sched == NULL) return; @@ -197,8 +197,8 @@ reset_clock ? "and clock counter" : ""); /* Free all potentially allocated timeslots */ - for (i = 0; i < ARRAY_SIZE(sched->ts); i++) - l1sched_del_ts(sched, i); + for (tn = 0; tn < ARRAY_SIZE(sched->ts); tn++) + l1sched_del_ts(sched, tn); /* Stop and reset clock counter if required */ if (reset_clock) -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28665
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I93b5a91341e7f79ced0591e13250632ba5e5adef Gerrit-Change-Number: 28665 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmocom-bb[master]: trxcon: cosmetic: s/app_evt_names/trxcon_fsm_event_names/
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28666
) Change subject: trxcon: cosmetic: s/app_evt_names/trxcon_fsm_event_names/ ...................................................................... trxcon: cosmetic: s/app_evt_names/trxcon_fsm_event_names/ Change-Id: Iae0e753eddb7e0a1767e555653c9e9fdb58b7a7b --- M src/host/trxcon/src/trxcon.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/66/28666/1 diff --git a/src/host/trxcon/src/trxcon.c b/src/host/trxcon/src/trxcon.c index 5a7f7a4..e7a7c1e 100644 --- a/src/host/trxcon/src/trxcon.c +++ b/src/host/trxcon/src/trxcon.c @@ -301,7 +301,7 @@ }, }; -static const struct value_string app_evt_names[] = { +static const struct value_string trxcon_fsm_event_names[] = { OSMO_VALUE_STRING(L1CTL_EVENT_CONNECT), OSMO_VALUE_STRING(L1CTL_EVENT_DISCONNECT), OSMO_VALUE_STRING(TRX_EVENT_OFFLINE), @@ -314,7 +314,7 @@ .states = trxcon_fsm_states, .num_states = ARRAY_SIZE(trxcon_fsm_states), .log_subsys = DAPP, - .event_names = app_evt_names, + .event_names = trxcon_fsm_event_names, }; static void print_usage(const char *app) -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28666
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Iae0e753eddb7e0a1767e555653c9e9fdb58b7a7b Gerrit-Change-Number: 28666 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmocom-bb[master]: trxcon: cosmetic: s/state/clck_state/ in struct l1sched_state
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28662
) Change subject: trxcon: cosmetic: s/state/clck_state/ in struct l1sched_state ...................................................................... trxcon: cosmetic: s/state/clck_state/ in struct l1sched_state Change-Id: I8a1b971abaf06c0b1339895cf1748c5eb21d45e6 --- M src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h M src/host/trxcon/src/sched_clck.c 2 files changed, 6 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/62/28662/1 diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h b/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h index 7cdb043..ae0bf9c 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h @@ -349,7 +349,7 @@ /*! One scheduler instance */ struct l1sched_state { /*! Clock state */ - enum l1sched_clck_state state; + enum l1sched_clck_state clck_state; /*! Local clock source */ struct timespec clock; /*! Count of processed frames */ diff --git a/src/host/trxcon/src/sched_clck.c b/src/host/trxcon/src/sched_clck.c index 5fb8d62..9c77382 100644 --- a/src/host/trxcon/src/sched_clck.c +++ b/src/host/trxcon/src/sched_clck.c @@ -55,7 +55,7 @@ /* Check if transceiver is still alive */ if (sched->fn_counter_lost++ == TRX_LOSS_FRAMES) { LOGP(DSCH, LOGL_DEBUG, "No more clock from transceiver\n"); - sched->state = L1SCHED_CLCK_ST_WAIT; + sched->clck_state = L1SCHED_CLCK_ST_WAIT; return; } @@ -72,7 +72,7 @@ LOGP(DSCH, LOGL_NOTICE, "PC clock skew: " "elapsed uS %" PRId64 "\n", elapsed_us); - sched->state = L1SCHED_CLCK_ST_WAIT; + sched->clck_state = L1SCHED_CLCK_ST_WAIT; return; } @@ -124,11 +124,11 @@ tv_clock = &sched->clock; /* If this is the first CLCK IND */ - if (sched->state == L1SCHED_CLCK_ST_WAIT) { + if (sched->clck_state == L1SCHED_CLCK_ST_WAIT) { l1sched_clck_correct(sched, &tv_now, fn); LOGP(DSCH, LOGL_DEBUG, "Initial clock received: fn=%u\n", fn); - sched->state = L1SCHED_CLCK_ST_OK; + sched->clck_state = L1SCHED_CLCK_ST_OK; return 0; } @@ -195,7 +195,7 @@ void l1sched_clck_reset(struct l1sched_state *sched) { /* Reset internal state */ - sched->state = L1SCHED_CLCK_ST_WAIT; + sched->clck_state = L1SCHED_CLCK_ST_WAIT; /* Stop clock timer */ osmo_timer_del(&sched->clock_timer); -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28662
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I8a1b971abaf06c0b1339895cf1748c5eb21d45e6 Gerrit-Change-Number: 28662 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmocom-bb[master]: trxcon: cosmetic: s/ts_list/ts/ in struct l1sched_state
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28663
) Change subject: trxcon: cosmetic: s/ts_list/ts/ in struct l1sched_state ...................................................................... trxcon: cosmetic: s/ts_list/ts/ in struct l1sched_state Change-Id: I182b2a3ae1dcb1671aaaed9394cdfea34f7966a9 --- M src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h M src/host/trxcon/src/l1ctl.c M src/host/trxcon/src/sched_prim.c M src/host/trxcon/src/sched_trx.c 4 files changed, 17 insertions(+), 17 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/63/28663/1 diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h b/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h index ae0bf9c..7b96f6d 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/l1sched.h @@ -363,7 +363,7 @@ /*! Frame callback */ void (*clock_cb)(struct l1sched_state *sched); /*! List of timeslots maintained by this scheduler */ - struct l1sched_ts *ts_list[TRX_TS_COUNT]; + struct l1sched_ts *ts[TRX_TS_COUNT]; /*! BSIC value learned from SCH bursts */ uint8_t bsic; }; diff --git a/src/host/trxcon/src/l1ctl.c b/src/host/trxcon/src/l1ctl.c index 526772b..fb8a203 100644 --- a/src/host/trxcon/src/l1ctl.c +++ b/src/host/trxcon/src/l1ctl.c @@ -482,7 +482,7 @@ req->ccch_mode); /* TODO: add value-string for ccch_mode */ /* Make sure that TS0 is allocated and configured */ - ts = l1l->sched->ts_list[0]; + ts = l1l->sched->ts[0]; if (ts == NULL || ts->mf_layout == NULL) { LOGP(DL1C, LOGL_ERROR, "TS0 is not configured"); rc = -EINVAL; @@ -659,7 +659,7 @@ /* Configure requested TS */ rc = l1sched_configure_ts(l1l->sched, tn, config); - ts = l1l->sched->ts_list[tn]; + ts = l1l->sched->ts[tn]; if (rc) { rc = -EINVAL; goto exit; @@ -767,7 +767,7 @@ /* Iterate over timeslot list */ for (i = 0; i < TRX_TS_COUNT; i++) { /* Timeslot is not allocated */ - ts = l1l->sched->ts_list[i]; + ts = l1l->sched->ts[i]; if (ts == NULL) continue; @@ -813,7 +813,7 @@ tn = ul->chan_nr & 0x7; /* Make sure that required TS is allocated and configured */ - ts = l1l->sched->ts_list[tn]; + ts = l1l->sched->ts[tn]; if (ts == NULL || ts->mf_layout == NULL) { LOGP(DL1C, LOGL_ERROR, "TS %u is not configured\n", tn); rc = -EINVAL; diff --git a/src/host/trxcon/src/sched_prim.c b/src/host/trxcon/src/sched_prim.c index 17d0141..bcc9bce 100644 --- a/src/host/trxcon/src/sched_prim.c +++ b/src/host/trxcon/src/sched_prim.c @@ -98,7 +98,7 @@ tn = chan_nr & 0x7; /* Check whether required timeslot is allocated and configured */ - ts = sched->ts_list[tn]; + ts = sched->ts[tn]; if (ts == NULL || ts->mf_layout == NULL) { LOGP(DSCH, LOGL_ERROR, "Timeslot %u isn't configured\n", tn); return NULL; diff --git a/src/host/trxcon/src/sched_trx.c b/src/host/trxcon/src/sched_trx.c index 55b5ed5..556ebcc 100644 --- a/src/host/trxcon/src/sched_trx.c +++ b/src/host/trxcon/src/sched_trx.c @@ -78,7 +78,7 @@ }; /* Timeslot is not allocated */ - ts = sched->ts_list[i]; + ts = sched->ts[i]; if (ts == NULL) continue; @@ -208,18 +208,18 @@ struct l1sched_ts *l1sched_add_ts(struct l1sched_state *sched, int tn) { /* Make sure that ts isn't allocated yet */ - if (sched->ts_list[tn] != NULL) { + if (sched->ts[tn] != NULL) { LOGP(DSCH, LOGL_ERROR, "Timeslot #%u already allocated\n", tn); return NULL; } LOGP(DSCH, LOGL_NOTICE, "Add a new TDMA timeslot #%u\n", tn); - sched->ts_list[tn] = talloc_zero(sched, struct l1sched_ts); - sched->ts_list[tn]->sched = sched; - sched->ts_list[tn]->index = tn; + sched->ts[tn] = talloc_zero(sched, struct l1sched_ts); + sched->ts[tn]->sched = sched; + sched->ts[tn]->index = tn; - return sched->ts_list[tn]; + return sched->ts[tn]; } void l1sched_del_ts(struct l1sched_state *sched, int tn) @@ -228,7 +228,7 @@ struct l1sched_ts *ts; /* Find ts in list */ - ts = sched->ts_list[tn]; + ts = sched->ts[tn]; if (ts == NULL) return; @@ -247,7 +247,7 @@ l1sched_prim_flush_queue(&ts->tx_prims); /* Remove ts from list and free memory */ - sched->ts_list[tn] = NULL; + sched->ts[tn] = NULL; talloc_free(ts); /* Notify transceiver about that */ @@ -265,7 +265,7 @@ struct l1sched_ts *ts; /* Try to find specified ts */ - ts = sched->ts_list[tn]; + ts = sched->ts[tn]; if (ts != NULL) { /* Reconfiguration of existing one */ l1sched_reset_ts(sched, tn); @@ -327,7 +327,7 @@ struct l1sched_ts *ts; /* Try to find specified ts */ - ts = sched->ts_list[tn]; + ts = sched->ts[tn]; if (ts == NULL) return -EINVAL; @@ -719,7 +719,7 @@ int rc; /* Check whether required timeslot is allocated and configured */ - ts = sched->ts_list[tn]; + ts = sched->ts[tn]; if (ts == NULL || ts->mf_layout == NULL) { LOGP(DSCHD, LOGL_DEBUG, "TDMA timeslot #%u isn't configured, " "ignoring burst...\n", tn); -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28663
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I182b2a3ae1dcb1671aaaed9394cdfea34f7966a9 Gerrit-Change-Number: 28663 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmocom-bb[master]: trxcon: add missing #include for enum gsm_phys_chan_config
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/28661
) Change subject: trxcon: add missing #include for enum gsm_phys_chan_config ...................................................................... trxcon: add missing #include for enum gsm_phys_chan_config Change-Id: I850b9a5c34fc39829c464b563f1a78ef4e8a1dd5 --- M src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/61/28661/1 diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h index e336225..4a59d67 100644 --- a/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h +++ b/src/host/trxcon/include/osmocom/bb/trxcon/trx_if.h @@ -5,6 +5,8 @@ #include <osmocom/core/timer.h> #include <osmocom/core/fsm.h> +#include <osmocom/gsm/gsm_utils.h> + #define TRXC_BUF_SIZE 1024 #define TRXD_BUF_SIZE 512 -- To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/28661
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I850b9a5c34fc39829c464b563f1a78ef4e8a1dd5 Gerrit-Change-Number: 28661 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in libosmocore[master]: tests/tdef: assert pointer returned by osmo_tdef_get_entry()
by fixeria
fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmocore/+/28660
) Change subject: tests/tdef: assert pointer returned by osmo_tdef_get_entry() ...................................................................... tests/tdef: assert pointer returned by osmo_tdef_get_entry() Coverity complains that we do check if osmo_tdef_get_entry() returns NULL 39 out of 40 times. Check it in test_tdef_set_and_get() too. Change-Id: I96041eab2786d850a49cb38a60a368cef2e476d3 Related: CID#274729 --- M tests/tdef/tdef_test.c 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/28660/1 diff --git a/tests/tdef/tdef_test.c b/tests/tdef/tdef_test.c index a2beb6a..c348e69 100644 --- a/tests/tdef/tdef_test.c +++ b/tests/tdef/tdef_test.c @@ -143,6 +143,7 @@ printf("setting 7 = 42\n"); t = osmo_tdef_get_entry(tdefs, 7); + OSMO_ASSERT(t != NULL); OSMO_ASSERT(osmo_tdef_val_in_range(t, 42)); t->val = 42; print_tdef_info(7); -- To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/28660
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I96041eab2786d850a49cb38a60a368cef2e476d3 Gerrit-Change-Number: 28660 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
2 years, 11 months
1
0
0
0
Change in osmo-cbc[master]: tests/sbcap: fix wrong operator used in OSMO_ASSERT statement
by fixeria
fixeria has uploaded a new patch set (#2). (
https://gerrit.osmocom.org/c/osmo-cbc/+/28659
) Change subject: tests/sbcap: fix wrong operator used in OSMO_ASSERT statement ...................................................................... tests/sbcap: fix wrong operator used in OSMO_ASSERT statement Change-Id: I6fe9080302166ad9bdc305eab736d51496dd1ff8 Related: CID#274972, CID#274971 --- M tests/sbcap/sbcap_test.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-cbc refs/changes/59/28659/2 -- To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28659
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc Gerrit-Branch: master Gerrit-Change-Id: I6fe9080302166ad9bdc305eab736d51496dd1ff8 Gerrit-Change-Number: 28659 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-MessageType: newpatchset
2 years, 11 months
1
0
0
0
← Newer
1
...
115
116
117
118
119
120
121
...
218
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Results per page:
10
25
50
100
200