lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • 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
gerrit-log@lists.osmocom.org

July 2023

  • 1 participants
  • 3051 discussions
[M] Change in osmocom-bb[master]: modem: handle OSMO_GPRS_RLCMAC_L1CTL_PDCH_{ESTABLISH,RELEASE}
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/33902 ) Change subject: modem: handle OSMO_GPRS_RLCMAC_L1CTL_PDCH_{ESTABLISH,RELEASE} ...................................................................... modem: handle OSMO_GPRS_RLCMAC_L1CTL_PDCH_{ESTABLISH,RELEASE} Change-Id: Ic39ce696834943dc661c85cbf3d54ccd598b60ce Depends: libosmo-gprs.git I2568c58646ce7511367275ac96cd55e7fdd7ec18 --- M src/host/layer23/src/modem/grr.c M src/host/layer23/src/modem/rlcmac.c 2 files changed, 57 insertions(+), 65 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/02/33902/1 diff --git a/src/host/layer23/src/modem/grr.c b/src/host/layer23/src/modem/grr.c index a7185fe..cf94695 100644 --- a/src/host/layer23/src/modem/grr.c +++ b/src/host/layer23/src/modem/grr.c @@ -226,8 +226,6 @@ { const struct gsm48_imm_ass *ia = msgb_l3(msg); struct gsm48_rrlayer *rr = &ms->rrlayer; - uint8_t ch_type, ch_subch, ch_ts; - int rc; /* 3GPP TS 44.018, section 10.5.2.25b "Dedicated mode or TBF". * As per table 9.1.18.1, only the value part (4 bits) is present in the @@ -269,68 +267,7 @@ } } - if (rsl_dec_chan_nr(ia->chan_desc.chan_nr, &ch_type, &ch_subch, &ch_ts) != 0) { - LOGP(DRR, LOGL_ERROR, "%s(): rsl_dec_chan_nr(chan_nr=0x%02x) failed\n", - __func__, ia->chan_desc.chan_nr); - return -EINVAL; - } - - /* FIXME: this event should be triggered by the RLC/MAC layers itself */ - rc = osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_ESTABLISH_REQ, NULL); - if (rc != 0) - return rc; - - if (!ia->chan_desc.h0.h) { - /* Non-hopping */ - uint16_t arfcn; - - arfcn = ia->chan_desc.h0.arfcn_low | (ia->chan_desc.h0.arfcn_high << 8); - - LOGP(DRR, LOGL_INFO, "GSM48 IMM ASS (ra=0x%02x, chan_nr=0x%02x, " - "ARFCN=%u, TS=%u, SS=%u, TSC=%u)\n", ia->req_ref.ra, - ia->chan_desc.chan_nr, arfcn, ch_ts, ch_subch, - ia->chan_desc.h0.tsc); - - l1ctl_tx_dm_est_req_h0(ms, arfcn, - RSL_CHAN_OSMO_PDCH | ch_ts, - ia->chan_desc.h0.tsc, GSM48_CMODE_SIGN, 0); - } else { - /* Hopping */ - uint8_t ma_len = 0; - uint8_t maio, hsn; - uint16_t ma[64]; - - hsn = ia->chan_desc.h1.hsn; - maio = ia->chan_desc.h1.maio_low | (ia->chan_desc.h1.maio_high << 2); - - LOGP(DRR, LOGL_INFO, "GSM48 IMM ASS (ra=0x%02x, chan_nr=0x%02x, " - "HSN=%u, MAIO=%u, TS=%u, SS=%u, TSC=%u)\n", ia->req_ref.ra, - ia->chan_desc.chan_nr, hsn, maio, ch_ts, ch_subch, - ia->chan_desc.h1.tsc); - - for (unsigned int i = 1, j = 0; i <= 1024; i++) { - unsigned int arfcn = i & 1023; - unsigned int k; - - if (~ms->cellsel.sel_si.freq[arfcn].mask & 0x01) - continue; - - k = ia->mob_alloc_len - (j >> 3) - 1; - if (ia->mob_alloc[k] & (1 << (j & 7))) - ma[ma_len++] = arfcn; - j++; - } - - l1ctl_tx_dm_est_req_h1(ms, maio, hsn, &ma[0], ma_len, - RSL_CHAN_OSMO_PDCH | ch_ts, - ia->chan_desc.h1.tsc, GSM48_CMODE_SIGN, 0); - } - - rc = forward_to_rlcmac(ms, msg); - if (rc < 0) - return rc; - - return 0; + return forward_to_rlcmac(ms, msg); } /* TS 44.018 9.1.22 "Paging request type 1" */ @@ -643,9 +580,50 @@ break; } case GRR_EV_PDCH_ESTABLISH_REQ: - /* TODO: send L1CTL_DM_EST_REQ here */ + { + const struct osmo_gprs_rlcmac_l1ctl_prim *lp = data; + + if (!lp->pdch_est_req.fh) { + LOGPFSML(fi, LOGL_INFO, + "PDCH Establish.Req: TSC=%u, H0, ARFCN=%u\n", + lp->pdch_est_req.tsc, lp->pdch_est_req.arfcn); + l1ctl_tx_dm_est_req_h0(ms, lp->pdch_est_req.arfcn, + RSL_CHAN_OSMO_PDCH | lp->pdch_est_req.ts_nr, + lp->pdch_est_req.tsc, GSM48_CMODE_SIGN, 0); + } else { + /* Hopping */ + uint8_t ma_len = 0; + uint16_t ma[64]; + + LOGPFSML(fi, LOGL_INFO, + "PDCH Establish.Req: TSC=%u, H1, HSN=%u, MAIO=%u\n", + lp->pdch_est_req.tsc, + lp->pdch_est_req.fhp.hsn, + lp->pdch_est_req.fhp.maio); + + for (unsigned int i = 1, j = 0; i <= 1024; i++) { + unsigned int arfcn = i & 1023; + unsigned int k; + + if (~ms->cellsel.sel_si.freq[arfcn].mask & 0x01) + continue; + + k = lp->pdch_est_req.fhp.ma_len - (j >> 3) - 1; + if (lp->pdch_est_req.fhp.ma[k] & (1 << (j & 7))) + ma[ma_len++] = arfcn; + j++; + } + + l1ctl_tx_dm_est_req_h1(ms, + lp->pdch_est_req.fhp.maio, + lp->pdch_est_req.fhp.hsn, + &ma[0], ma_len, + RSL_CHAN_OSMO_PDCH | lp->pdch_est_req.ts_nr, + lp->pdch_est_req.tsc, GSM48_CMODE_SIGN, 0); + } osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_TRANSFER, 0, 0); break; + } default: OSMO_ASSERT(0); } diff --git a/src/host/layer23/src/modem/rlcmac.c b/src/host/layer23/src/modem/rlcmac.c index d209ec4..0f98e79 100644 --- a/src/host/layer23/src/modem/rlcmac.c +++ b/src/host/layer23/src/modem/rlcmac.c @@ -152,6 +152,10 @@ return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_UL_TBF_CFG_REQ, lp); case OSMO_PRIM(OSMO_GPRS_RLCMAC_L1CTL_CFG_DL_TBF, PRIM_OP_REQUEST): return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_DL_TBF_CFG_REQ, lp); + case OSMO_PRIM(OSMO_GPRS_RLCMAC_L1CTL_PDCH_ESTABLISH, PRIM_OP_REQUEST): + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_ESTABLISH_REQ, lp); + case OSMO_PRIM(OSMO_GPRS_RLCMAC_L1CTL_PDCH_RELEASE, PRIM_OP_REQUEST): + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_RELEASE_REQ, lp); default: LOGP(DRLCMAC, LOGL_DEBUG, "%s(): Unexpected Rx %s\n", __func__, pdu_name); OSMO_ASSERT(0); -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/33902 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ic39ce696834943dc661c85cbf3d54ccd598b60ce Gerrit-Change-Number: 33902 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmocom-bb[master]: trxcon: trx_if_cmd_poweron(): send CMD POWERON unconditionally
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/33903 ) Change subject: trxcon: trx_if_cmd_poweron(): send CMD POWERON unconditionally ...................................................................... trxcon: trx_if_cmd_poweron(): send CMD POWERON unconditionally This works-around a race condition happening when the upper layers are sending L1CTL RESET.req immediately followed by L1CTL FBSB.req. The problem is that the TRXC logic is considering the transceiver powered on until a response to CMD POWEROFF is received. Change-Id: I967ce047eb198f1eaf8446bb4c1f87a98d3de264 Related: OS#5500 --- M src/host/trxcon/src/trx_if.c 1 file changed, 17 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/03/33903/1 diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c index d98bea2..fad1026 100644 --- a/src/host/trxcon/src/trx_if.c +++ b/src/host/trxcon/src/trx_if.c @@ -261,8 +261,10 @@ static int trx_if_cmd_poweron(struct trx_instance *trx) { +#if 0 if (trx->powered_up) return -EAGAIN; +#endif return trx_ctrl_cmd(trx, 1, "POWERON", ""); } -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/33903 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I967ce047eb198f1eaf8446bb4c1f87a98d3de264 Gerrit-Change-Number: 33903 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmocom-bb[master]: layer23: modem: Avoid direct transition ST_PACKET_TRANSFER->ST_PACKET...
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/33906 ) Change subject: layer23: modem: Avoid direct transition ST_PACKET_TRANSFER->ST_PACKET_IDLE ...................................................................... layer23: modem: Avoid direct transition ST_PACKET_TRANSFER->ST_PACKET_IDLE Right now the existing code is switching to state IDLE and hence running grr_st_packet_idle_onenter() which attempts stuff like starting an attach. This is all done while the L1CTL RESET + FBSB is still in progress. We should instead wait to receive confirmation from those. As an easy implementation for now, simply switch to the GRR_ST_PACKET_NOT_READY state, which will move to GRR_ST_PACKET_IDLE once it starts receiving CCCH blocks (aka it will already have gone through L1CTL RESET + FBSB completely). Change-Id: Ie797b36701d10c6052500c637a08b061bb1e4bd7 --- M src/host/layer23/src/modem/grr.c 1 file changed, 20 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/06/33906/1 diff --git a/src/host/layer23/src/modem/grr.c b/src/host/layer23/src/modem/grr.c index 2047eef..12d7059 100644 --- a/src/host/layer23/src/modem/grr.c +++ b/src/host/layer23/src/modem/grr.c @@ -688,7 +688,7 @@ break; case GRR_EV_PDCH_RELEASE_REQ: modem_sync_to_cell(ms); - osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_IDLE, 0, 0); + osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_NOT_READY, 0, 0); break; default: OSMO_ASSERT(0); @@ -717,8 +717,7 @@ }, [GRR_ST_PACKET_TRANSFER] = { .name = "PACKET_TRANSFER", - .out_state_mask = S(GRR_ST_PACKET_NOT_READY) - | S(GRR_ST_PACKET_IDLE), + .out_state_mask = S(GRR_ST_PACKET_NOT_READY), .in_event_mask = S(GRR_EV_PDCH_UL_TBF_CFG_REQ) | S(GRR_EV_PDCH_DL_TBF_CFG_REQ) | S(GRR_EV_PDCH_BLOCK_REQ) -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/33906 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ie797b36701d10c6052500c637a08b061bb1e4bd7 Gerrit-Change-Number: 33906 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[L] Change in osmocom-bb[master]: [WIP] modem: implement GPRS-RR FSM
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/33901 ) Change subject: [WIP] modem: implement GPRS-RR FSM ...................................................................... [WIP] modem: implement GPRS-RR FSM Change-Id: I8a7d85df7b07d85ac86e0b7e340f6bbacc65e1bc --- M src/host/layer23/include/osmocom/bb/common/ms.h M src/host/layer23/include/osmocom/bb/modem/grr.h M src/host/layer23/src/modem/app_modem.c M src/host/layer23/src/modem/grr.c M src/host/layer23/src/modem/rlcmac.c M src/host/layer23/src/modem/vty.c 6 files changed, 350 insertions(+), 133 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/01/33901/1 diff --git a/src/host/layer23/include/osmocom/bb/common/ms.h b/src/host/layer23/include/osmocom/bb/common/ms.h index bfbf879..8d1ffc4 100644 --- a/src/host/layer23/include/osmocom/bb/common/ms.h +++ b/src/host/layer23/include/osmocom/bb/common/ms.h @@ -100,6 +100,7 @@ /* GPRS */ struct gprs_settings gprs; struct osmobb_ms_gmm_layer gmmlayer; + struct osmo_fsm_inst *grr_fi; /* Audio I/O */ struct gapk_io_state *gapk_io; diff --git a/src/host/layer23/include/osmocom/bb/modem/grr.h b/src/host/layer23/include/osmocom/bb/modem/grr.h index 1f2b08c..3472a10 100644 --- a/src/host/layer23/include/osmocom/bb/modem/grr.h +++ b/src/host/layer23/include/osmocom/bb/modem/grr.h @@ -6,7 +6,28 @@ struct msgb; struct osmocom_ms; struct lapdm_entity; +struct osmo_fsm; + +enum grr_fsm_state { + GRR_ST_PACKET_NOT_READY, + GRR_ST_PACKET_IDLE, + GRR_ST_PACKET_TRANSFER, +}; + +enum grr_fsm_event { + GRR_EV_BCCH_BLOCK_IND, + GRR_EV_PCH_AGCH_BLOCK_IND, + GRR_EV_RACH_REQ, + GRR_EV_RACH_CNF, + GRR_EV_PDCH_ESTABLISH_REQ, + GRR_EV_PDCH_RELEASE_REQ, + GRR_EV_PDCH_UL_TBF_CFG_REQ, + GRR_EV_PDCH_DL_TBF_CFG_REQ, + GRR_EV_PDCH_BLOCK_REQ, + GRR_EV_PDCH_BLOCK_IND, +}; + +extern struct osmo_fsm grr_fsm_def; int modem_grr_rslms_cb(struct msgb *msg, struct lapdm_entity *le, void *ctx); -int modem_grr_tx_chan_req(struct osmocom_ms *ms, uint8_t chan_req); uint8_t modem_grr_gen_chan_req(bool single_block); diff --git a/src/host/layer23/src/modem/app_modem.c b/src/host/layer23/src/modem/app_modem.c index fdb3821..6871384 100644 --- a/src/host/layer23/src/modem/app_modem.c +++ b/src/host/layer23/src/modem/app_modem.c @@ -62,34 +62,6 @@ struct modem_app app_data; -static bool modem_can_gprs_attach(const struct osmocom_ms *ms) -{ - const struct gsm_subscriber *subscr = &ms->subscr; - const struct gsm322_cellsel *cs = &ms->cellsel; - const struct gsm48_sysinfo *si = &cs->sel_si; - - if (!subscr->sim_valid) - goto ret_false; - - if (!si->si1 || !si->si3 || !si->si4 || !si->si13) - goto ret_false; - - if (!si->gprs.supported) - goto ret_false; - - return true; - -ret_false: - LOGP(DRLCMAC, LOGL_INFO, "Delaying GPRS attach, waiting for:%s%s%s%s%s%s\n", - subscr->sim_valid ? "" : " imsi", - si->si1 ? "" : " si1", - si->si3 ? "" : " si3", - si->si4 ? "" : " si4", - si->si13 ? "" : " si13", - si->gprs.supported ? "" : " GprsIndicator"); - return false; -} - int modem_gprs_attach_if_needed(struct osmocom_ms *ms) { int rc; @@ -97,7 +69,10 @@ if (app_data.modem_state != MODEM_ST_IDLE) return 0; - if (!modem_can_gprs_attach(ms)) + if (ms->grr_fi->state == GRR_ST_PACKET_NOT_READY) + return 0; + + if (!ms->subscr.sim_valid) return 0; app_data.modem_state = MODEM_ST_ATTACHING; @@ -201,6 +176,8 @@ switch (signal) { case S_L1CTL_RESET: ms = signal_data; + if (ms->started) + break; layer3_app_reset(); app_data.ms = ms; @@ -285,6 +262,12 @@ return rc; } + /* TODO: move to a separate function */ + app_data.ms->grr_fi = osmo_fsm_inst_alloc(&grr_fsm_def, NULL, + app_data.ms, LOGL_DEBUG, + app_data.ms->name); + OSMO_ASSERT(app_data.ms->grr_fi != NULL); + osmo_signal_register_handler(SS_L1CTL, &global_signal_cb, NULL); osmo_signal_register_handler(SS_L23_SUBSCR, &modem_l23_subscr_signal_cb, NULL); lapdm_channel_set_l3(&app_data.ms->lapdm_channel, &modem_grr_rslms_cb, app_data.ms); diff --git a/src/host/layer23/src/modem/grr.c b/src/host/layer23/src/modem/grr.c index bd55f30..a7185fe 100644 --- a/src/host/layer23/src/modem/grr.c +++ b/src/host/layer23/src/modem/grr.c @@ -1,5 +1,8 @@ /* * (C) 2022-2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Pau Espin Pedrol <pespin(a)sysmocom.de> + * Author: Vadim Yanitskiy <vyanitskiy(a)sysmocom.de> + * * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -23,6 +26,7 @@ #include <string.h> #include <errno.h> +#include <osmocom/core/fsm.h> #include <osmocom/core/msgb.h> #include <osmocom/core/utils.h> #include <osmocom/core/logging.h> @@ -41,6 +45,7 @@ #include <osmocom/bb/common/l1ctl.h> #include <osmocom/bb/common/ms.h> #include <osmocom/bb/modem/modem.h> +#include <osmocom/bb/modem/grr.h> #include <osmocom/bb/mobile/gsm322.h> #include <osmocom/bb/mobile/gsm48_rr.h> @@ -87,29 +92,6 @@ return false; } -int modem_grr_tx_chan_req(struct osmocom_ms *ms, uint8_t chan_req) -{ - struct gsm322_cellsel *cs = &ms->cellsel; - struct gsm48_rrlayer *rr = &ms->rrlayer; - - OSMO_ASSERT(rr->state == GSM48_RR_ST_IDLE); - - if (!cs->sel_si.si1 || !cs->sel_si.si13) - return -EAGAIN; - if (!cs->sel_si.gprs.supported) - return -ENOTSUP; - - rr->cr_ra = chan_req; - memset(&rr->cr_hist[0], 0x00, sizeof(rr->cr_hist)); - - LOGP(DRR, LOGL_NOTICE, "Sending CHANNEL REQUEST (0x%02x)\n", rr->cr_ra); - l1ctl_tx_rach_req(ms, RSL_CHAN_RACH, 0x00, rr->cr_ra, 0, - cs->ccch_mode == CCCH_MODE_COMBINED); - - rr->state = GSM48_RR_ST_CONN_PEND; - return 0; -} - static int forward_to_rlcmac(struct osmocom_ms *ms, struct msgb *msg) { struct osmo_gprs_rlcmac_prim *rlcmac_prim; @@ -135,7 +117,6 @@ return rc; } - modem_gprs_attach_if_needed(ms); return 0; } @@ -171,7 +152,6 @@ LOGP(DRR, LOGL_NOTICE, "Found GPRS Indicator (RA Colour %u, SI13 on BCCH %s)\n", cs->sel_si.gprs.ra_colour, cs->sel_si.gprs.si13_pos ? "Ext" : "Norm"); - modem_gprs_attach_if_needed(ms); return 0; } @@ -199,7 +179,6 @@ LOGP(DRR, LOGL_NOTICE, "Found GPRS Indicator (RA Colour %u, SI13 on BCCH %s)\n", cs->sel_si.gprs.ra_colour, cs->sel_si.gprs.si13_pos ? "Ext" : "Norm"); - modem_gprs_attach_if_needed(ms); return 0; } @@ -218,10 +197,7 @@ return rc; /* Forward SI13 to RLC/MAC layer */ - rc = forward_to_rlcmac(ms, msg); - - modem_gprs_attach_if_needed(ms); - return rc; + return forward_to_rlcmac(ms, msg); } static int grr_rx_bcch(struct osmocom_ms *ms, struct msgb *msg) @@ -299,6 +275,11 @@ return -EINVAL; } + /* FIXME: this event should be triggered by the RLC/MAC layers itself */ + rc = osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_ESTABLISH_REQ, NULL); + if (rc != 0) + return rc; + if (!ia->chan_desc.h0.h) { /* Non-hopping */ uint16_t arfcn; @@ -349,7 +330,6 @@ if (rc < 0) return rc; - rr->state = GSM48_RR_ST_DEDICATED; return 0; } @@ -461,9 +441,9 @@ switch (rllh->chan_nr) { case RSL_CHAN_PCH_AGCH: - return grr_rx_ccch(ms, msg); + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PCH_AGCH_BLOCK_IND, msg); case RSL_CHAN_BCCH: - return grr_rx_bcch(ms, msg); + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_BCCH_BLOCK_IND, msg); default: return 0; } @@ -486,25 +466,11 @@ static int grr_rx_rslms_cchan(struct osmocom_ms *ms, struct msgb *msg) { const struct abis_rsl_cchan_hdr *ch = msgb_l2(msg); - struct gsm48_rrlayer *rr = &ms->rrlayer; switch (ch->c.msg_type) { case RSL_MT_CHAN_CONF: /* RACH.conf */ - if (rr->state == GSM48_RR_ST_CONN_PEND) { - const struct gsm48_req_ref *ref = (void *)&ch->data[1]; - LOGP(DRSL, LOGL_NOTICE, - "Rx RACH.conf (RA=0x%02x, T1=%u, T3=%u, T2=%u, FN=%u)\n", - rr->cr_ra, ref->t1, ref->t3_high << 3 | ref->t3_low, ref->t2, - _gsm48_req_ref2fn(ref)); - /* shift the CHANNEL REQUEST history buffer */ - memmove(&rr->cr_hist[1], &rr->cr_hist[0], ARRAY_SIZE(rr->cr_hist) - 1); - /* store the new entry */ - rr->cr_hist[0].ref = *ref; - rr->cr_hist[0].ref.ra = rr->cr_ra; - rr->cr_hist[0].valid = 1; - return 0; - } - /* fall-through */ + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_RACH_CNF, + (void *)&ch->data[1]); default: LOGP(DRSL, LOGL_NOTICE, "Unhandled RSLms CCHAN message " "(msg_type 0x%02x)\n", ch->c.msg_type); @@ -534,3 +500,277 @@ msgb_free(msg); return rc; } + +///////////////////////////////////////////////////////////////////////////////////////// + +#define S(x) (1 << (x)) + +#include <osmocom/gsm/gsm0502.h> // XXX + +static void handle_pdch_block_ind(struct osmocom_ms *ms, struct msgb *msg) +{ + const struct l1ctl_gprs_dl_block_ind *ind = (void *)msg->l1h; + const uint32_t fn = osmo_load32be(&ind->hdr.fn); + struct osmo_gprs_rlcmac_prim *prim; + + /* FIXME: sadly, rlcmac_prim_l1ctl_alloc() is not exposed */ + prim = osmo_gprs_rlcmac_prim_alloc_l1ctl_pdch_data_ind(0, 0, 0, 0, 0, NULL, 0); + prim->l1ctl = (struct osmo_gprs_rlcmac_l1ctl_prim) { + .pdch_data_ind = { + .fn = fn, + .ts_nr = ind->hdr.tn, + .rx_lev = ind->meas.rx_lev, + .ber10k = osmo_load16be(&ind->meas.ber10k), + .ci_cb = osmo_load16be(&ind->meas.ci_cb), + .data_len = msgb_l2len(msg), + .data = msgb_l2(msg), + } + }; + osmo_gprs_rlcmac_prim_lower_up(prim); + + /* Do not send RTS.ind if we got PTCCH/D */ + if (fn % 104 == 12) + return; + + /* Every fn % 13 == 12 we have either a PTCCH or an IDLE slot, thus + * every fn % 13 == 8 we add 5 frames, or 4 frames othrwise. The + * resulting value is first fn of the next block. */ + const uint32_t rts_fn = GSM_TDMA_FN_SUM(fn, (fn % 13 == 8) ? 5 : 4); + prim = osmo_gprs_rlcmac_prim_alloc_l1ctl_pdch_rts_ind(ind->hdr.tn, rts_fn, ind->usf); + osmo_gprs_rlcmac_prim_lower_up(prim); +} + +static bool grr_cell_is_usable(const struct osmocom_ms *ms) +{ + const struct gsm322_cellsel *cs = &ms->cellsel; + const struct gsm48_sysinfo *si = &cs->sel_si; + + if (!si->si1 || !si->si3 || !si->si4 || !si->si13) + return false; + if (!si->gprs.supported) + return false; + + return true; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +static void grr_st_packet_not_ready_action(struct osmo_fsm_inst *fi, + uint32_t event, void *data) +{ + struct osmocom_ms *ms = fi->priv; + + switch (event) { + case GRR_EV_BCCH_BLOCK_IND: + grr_rx_bcch(ms, (struct msgb *)data); + if (grr_cell_is_usable(ms)) { + LOGPFSML(fi, LOGL_NOTICE, "Cell is usable, GRR becomes ready\n"); + osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_IDLE, 0, 0); + } + break; + case GRR_EV_PCH_AGCH_BLOCK_IND: + grr_rx_ccch(ms, (struct msgb *)data); + break; + default: + OSMO_ASSERT(0); + } +} + +static void grr_st_packet_idle_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct osmocom_ms *ms = fi->priv; + + modem_gprs_attach_if_needed(ms); +} + +static void grr_st_packet_idle_action(struct osmo_fsm_inst *fi, + uint32_t event, void *data) +{ + struct osmocom_ms *ms = fi->priv; + + switch (event) { + case GRR_EV_BCCH_BLOCK_IND: + grr_rx_bcch(ms, (struct msgb *)data); + if (!grr_cell_is_usable(ms)) { + LOGPFSML(fi, LOGL_NOTICE, "Cell is not usable, GRR becomes not ready\n"); + osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_NOT_READY, 0, 0); + } + break; + case GRR_EV_PCH_AGCH_BLOCK_IND: + grr_rx_ccch(ms, (struct msgb *)data); + break; + case GRR_EV_RACH_REQ: + { + const struct osmo_gprs_rlcmac_l1ctl_prim *lp = data; + struct gsm48_rrlayer *rr = &ms->rrlayer; + + if (lp->rach_req.is_11bit) { /* TODO: implement 11-bit RACH */ + LOGPFSML(fi, LOGL_ERROR, "11-bit RACH is not supported\n"); + return; + } + + rr->cr_ra = lp->rach_req.ra; + memset(&rr->cr_hist[0], 0x00, sizeof(rr->cr_hist)); + + LOGPFSML(fi, LOGL_INFO, "Sending CHANNEL REQUEST (0x%02x)\n", rr->cr_ra); + l1ctl_tx_rach_req(ms, RSL_CHAN_RACH, 0x00, rr->cr_ra, 0, + ms->cellsel.ccch_mode == CCCH_MODE_COMBINED); + + rr->state = GSM48_RR_ST_CONN_PEND; + break; + } + case GRR_EV_RACH_CNF: + { + struct gsm48_rrlayer *rr = &ms->rrlayer; + const struct gsm48_req_ref *ref = data; + + LOGPFSML(fi, LOGL_NOTICE, + "Rx RACH.conf (RA=0x%02x, T1=%u, T3=%u, T2=%u, FN=%u)\n", + rr->cr_ra, ref->t1, ref->t3_high << 3 | ref->t3_low, ref->t2, + _gsm48_req_ref2fn(ref)); + + if (ms->rrlayer.state != GSM48_RR_ST_CONN_PEND) { + LOGPFSML(fi, LOGL_ERROR, "Rx unexpected RACH.conf\n"); + return; + } + + /* shift the CHANNEL REQUEST history buffer */ + memmove(&rr->cr_hist[1], &rr->cr_hist[0], ARRAY_SIZE(rr->cr_hist) - 1); + /* store the new entry */ + rr->cr_hist[0].ref = *ref; + rr->cr_hist[0].ref.ra = rr->cr_ra; + rr->cr_hist[0].valid = 1; + break; + } + case GRR_EV_PDCH_ESTABLISH_REQ: + /* TODO: send L1CTL_DM_EST_REQ here */ + osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_TRANSFER, 0, 0); + break; + default: + OSMO_ASSERT(0); + } +} + +static void grr_st_packet_transfer_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct osmocom_ms *ms = fi->priv; + + ms->rrlayer.state = GSM48_RR_ST_DEDICATED; +} + +static void grr_st_packet_transfer_onleave(struct osmo_fsm_inst *fi, uint32_t next_state) +{ + struct osmocom_ms *ms = fi->priv; + + ms->rrlayer.state = GSM48_RR_ST_IDLE; +} + +static void grr_st_packet_transfer_action(struct osmo_fsm_inst *fi, + uint32_t event, void *data) +{ + struct osmocom_ms *ms = fi->priv; + + switch (event) { + case GRR_EV_PDCH_UL_TBF_CFG_REQ: + { + const struct osmo_gprs_rlcmac_l1ctl_prim *lp = data; + l1ctl_tx_gprs_ul_tbf_cfg_req(ms, + lp->cfg_ul_tbf_req.ul_tbf_nr, + lp->cfg_ul_tbf_req.ul_slotmask); + break; + } + case GRR_EV_PDCH_DL_TBF_CFG_REQ: + { + const struct osmo_gprs_rlcmac_l1ctl_prim *lp = data; + l1ctl_tx_gprs_dl_tbf_cfg_req(ms, + lp->cfg_dl_tbf_req.dl_tbf_nr, + lp->cfg_dl_tbf_req.dl_slotmask, + lp->cfg_dl_tbf_req.dl_tfi); + break; + } + case GRR_EV_PDCH_BLOCK_REQ: + { + const struct osmo_gprs_rlcmac_l1ctl_prim *lp = data; + l1ctl_tx_gprs_ul_block_req(ms, + lp->pdch_data_req.fn, + lp->pdch_data_req.ts_nr, + lp->pdch_data_req.data, + lp->pdch_data_req.data_len); + break; + } + case GRR_EV_PDCH_BLOCK_IND: + handle_pdch_block_ind(ms, (struct msgb *)data); + break; + case GRR_EV_PDCH_RELEASE_REQ: + l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL); + l1ctl_tx_fbsb_req(ms, ms->test_arfcn, + L1CTL_FBSB_F_FB01SB, 100, 0, + ms->cellsel.ccch_mode, dbm2rxlev(-85)); + osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_IDLE, 0, 0); + break; + default: + OSMO_ASSERT(0); + } +} + +static const struct osmo_fsm_state grr_fsm_states[] = { + [GRR_ST_PACKET_NOT_READY] = { + .name = "PACKET_NOT_READY", + .out_state_mask = S(GRR_ST_PACKET_IDLE), + .in_event_mask = S(GRR_EV_BCCH_BLOCK_IND) + | S(GRR_EV_PCH_AGCH_BLOCK_IND), + .action = &grr_st_packet_not_ready_action, + }, + [GRR_ST_PACKET_IDLE] = { + .name = "PACKET_IDLE", + .out_state_mask = S(GRR_ST_PACKET_NOT_READY) + | S(GRR_ST_PACKET_TRANSFER), + .in_event_mask = S(GRR_EV_BCCH_BLOCK_IND) + | S(GRR_EV_PCH_AGCH_BLOCK_IND) + | S(GRR_EV_RACH_REQ) + | S(GRR_EV_RACH_CNF) + | S(GRR_EV_PDCH_ESTABLISH_REQ), + .action = &grr_st_packet_idle_action, + .onenter = &grr_st_packet_idle_onenter, + }, + [GRR_ST_PACKET_TRANSFER] = { + .name = "PACKET_TRANSFER", + .out_state_mask = S(GRR_ST_PACKET_NOT_READY) + | S(GRR_ST_PACKET_IDLE), + .in_event_mask = S(GRR_EV_PDCH_UL_TBF_CFG_REQ) + | S(GRR_EV_PDCH_DL_TBF_CFG_REQ) + | S(GRR_EV_PDCH_BLOCK_REQ) + | S(GRR_EV_PDCH_BLOCK_IND) + | S(GRR_EV_PDCH_RELEASE_REQ), + .action = &grr_st_packet_transfer_action, + .onenter = &grr_st_packet_transfer_onenter, + .onleave = &grr_st_packet_transfer_onleave, + }, +}; + +static const struct value_string grr_fsm_event_names[] = { + OSMO_VALUE_STRING(GRR_EV_BCCH_BLOCK_IND), + OSMO_VALUE_STRING(GRR_EV_PCH_AGCH_BLOCK_IND), + OSMO_VALUE_STRING(GRR_EV_RACH_REQ), + OSMO_VALUE_STRING(GRR_EV_RACH_CNF), + OSMO_VALUE_STRING(GRR_EV_PDCH_ESTABLISH_REQ), + OSMO_VALUE_STRING(GRR_EV_PDCH_RELEASE_REQ), + OSMO_VALUE_STRING(GRR_EV_PDCH_UL_TBF_CFG_REQ), + OSMO_VALUE_STRING(GRR_EV_PDCH_DL_TBF_CFG_REQ), + OSMO_VALUE_STRING(GRR_EV_PDCH_BLOCK_REQ), + OSMO_VALUE_STRING(GRR_EV_PDCH_BLOCK_IND), + { 0, NULL } +}; + +struct osmo_fsm grr_fsm_def = { + .name = "GPRS-RR", + .log_subsys = DRR, + .states = grr_fsm_states, + .num_states = ARRAY_SIZE(grr_fsm_states), + .event_names = grr_fsm_event_names, +}; + +static __attribute__((constructor)) void on_dso_load(void) +{ + OSMO_ASSERT(osmo_fsm_register(&grr_fsm_def) == 0); +} diff --git a/src/host/layer23/src/modem/rlcmac.c b/src/host/layer23/src/modem/rlcmac.c index fcd2b2e..d209ec4 100644 --- a/src/host/layer23/src/modem/rlcmac.c +++ b/src/host/layer23/src/modem/rlcmac.c @@ -22,6 +22,7 @@ #include <stdint.h> #include <stdbool.h> +#include <osmocom/core/fsm.h> #include <osmocom/core/msgb.h> #include <osmocom/core/bits.h> #include <osmocom/core/prim.h> @@ -38,13 +39,10 @@ #include <osmocom/gprs/gmm/gmm_prim.h> #include <osmocom/bb/common/logging.h> -#include <osmocom/bb/common/l1ctl.h> #include <osmocom/bb/common/ms.h> #include <osmocom/bb/modem/rlcmac.h> #include <osmocom/bb/modem/grr.h> -#include <l1ctl_proto.h> - static int modem_rlcmac_handle_grr(struct osmo_gprs_rlcmac_prim *rlcmac_prim) { int rc; @@ -141,33 +139,19 @@ static int modem_rlcmac_prim_down_cb(struct osmo_gprs_rlcmac_prim *prim, void *user_data) { - const struct osmo_gprs_rlcmac_l1ctl_prim *lp = &prim->l1ctl; + struct osmo_gprs_rlcmac_l1ctl_prim *lp = &prim->l1ctl; const char *pdu_name = osmo_gprs_rlcmac_prim_name(prim); struct osmocom_ms *ms = user_data; switch (OSMO_PRIM_HDR(&prim->oph)) { case OSMO_PRIM(OSMO_GPRS_RLCMAC_L1CTL_RACH, PRIM_OP_REQUEST): - if (lp->rach_req.is_11bit) { - LOGP(DRLCMAC, LOGL_NOTICE, - "%s(): 11-bit RACH is not supported\n", __func__); - return -ENOTSUP; - } - return modem_grr_tx_chan_req(ms, lp->rach_req.ra); + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_RACH_REQ, lp); case OSMO_PRIM(OSMO_GPRS_RLCMAC_L1CTL_PDCH_DATA, PRIM_OP_REQUEST): - return l1ctl_tx_gprs_ul_block_req(ms, - lp->pdch_data_req.fn, - lp->pdch_data_req.ts_nr, - lp->pdch_data_req.data, - lp->pdch_data_req.data_len); + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_BLOCK_REQ, lp); case OSMO_PRIM(OSMO_GPRS_RLCMAC_L1CTL_CFG_UL_TBF, PRIM_OP_REQUEST): - return l1ctl_tx_gprs_ul_tbf_cfg_req(ms, - lp->cfg_ul_tbf_req.ul_tbf_nr, - lp->cfg_ul_tbf_req.ul_slotmask); + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_UL_TBF_CFG_REQ, lp); case OSMO_PRIM(OSMO_GPRS_RLCMAC_L1CTL_CFG_DL_TBF, PRIM_OP_REQUEST): - return l1ctl_tx_gprs_dl_tbf_cfg_req(ms, - lp->cfg_dl_tbf_req.dl_tbf_nr, - lp->cfg_dl_tbf_req.dl_slotmask, - lp->cfg_dl_tbf_req.dl_tfi); + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_DL_TBF_CFG_REQ, lp); default: LOGP(DRLCMAC, LOGL_DEBUG, "%s(): Unexpected Rx %s\n", __func__, pdu_name); OSMO_ASSERT(0); @@ -176,37 +160,7 @@ static int l1ctl_dl_block_cb(struct osmocom_ms *ms, struct msgb *msg) { - const struct l1ctl_gprs_dl_block_ind *ind = (void *)msg->l1h; - const uint32_t fn = osmo_load32be(&ind->hdr.fn); - struct osmo_gprs_rlcmac_prim *prim; - - /* FIXME: sadly, rlcmac_prim_l1ctl_alloc() is not exposed */ - prim = osmo_gprs_rlcmac_prim_alloc_l1ctl_pdch_data_ind(0, 0, 0, 0, 0, NULL, 0); - prim->l1ctl = (struct osmo_gprs_rlcmac_l1ctl_prim) { - .pdch_data_ind = { - .fn = fn, - .ts_nr = ind->hdr.tn, - .rx_lev = ind->meas.rx_lev, - .ber10k = osmo_load16be(&ind->meas.ber10k), - .ci_cb = osmo_load16be(&ind->meas.ci_cb), - .data_len = msgb_l2len(msg), - .data = msgb_l2(msg), - } - }; - osmo_gprs_rlcmac_prim_lower_up(prim); - - /* Do not send RTS.ind if we got PTCCH/D */ - if (fn % 104 == 12) - return 0; - - /* Every fn % 13 == 12 we have either a PTCCH or an IDLE slot, thus - * every fn % 13 == 8 we add 5 frames, or 4 frames othrwise. The - * resulting value is first fn of the next block. */ - const uint32_t rts_fn = GSM_TDMA_FN_SUM(fn, (fn % 13 == 8) ? 5 : 4); - prim = osmo_gprs_rlcmac_prim_alloc_l1ctl_pdch_rts_ind(ind->hdr.tn, rts_fn, ind->usf); - osmo_gprs_rlcmac_prim_lower_up(prim); - - return 0; + return osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_PDCH_BLOCK_IND, msg); } int modem_rlcmac_init(struct osmocom_ms *ms) diff --git a/src/host/layer23/src/modem/vty.c b/src/host/layer23/src/modem/vty.c index d827993..da29165 100644 --- a/src/host/layer23/src/modem/vty.c +++ b/src/host/layer23/src/modem/vty.c @@ -19,6 +19,7 @@ #include <stdint.h> #include <stdbool.h> +#include <osmocom/core/fsm.h> #include <osmocom/core/utils.h> #include <osmocom/core/talloc.h> #include <osmocom/core/linuxlist.h> @@ -27,6 +28,7 @@ #include <osmocom/gprs/llc/llc_prim.h> #include <osmocom/gprs/gmm/gmm_prim.h> #include <osmocom/gprs/sm/sm_prim.h> +#include <osmocom/gprs/rlcmac/rlcmac_prim.h> #include <osmocom/vty/vty.h> @@ -84,7 +86,14 @@ return CMD_WARNING; chan_req = modem_grr_gen_chan_req(argv[1][0] == '2'); - if (modem_grr_tx_chan_req(ms, chan_req) != 0) { + const struct osmo_gprs_rlcmac_l1ctl_prim lp = { + .rach_req = { + .is_11bit = false, + .ra = chan_req, + } + }; + + if (osmo_fsm_inst_dispatch(ms->grr_fi, GRR_EV_RACH_REQ, (void *)&lp)) { vty_out(vty, "Failed to send a CHANNEL REQUEST%s", VTY_NEWLINE); return CMD_WARNING; } -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/33901 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I8a7d85df7b07d85ac86e0b7e340f6bbacc65e1bc Gerrit-Change-Number: 33901 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmocom-bb[master]: layer23: modem: Submit L1CTL-CCCH_READY.ind
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/33904 ) Change subject: layer23: modem: Submit L1CTL-CCCH_READY.ind ...................................................................... layer23: modem: Submit L1CTL-CCCH_READY.ind Signal RLC/MAC layer that the lower layers is in packet idle mode ready to use CCCH (such as packet-access-procedure). Change-Id: I05050e840a3b267b3b3a278588ee113b45bfbd4c --- M src/host/layer23/src/modem/grr.c 1 file changed, 16 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/04/33904/1 diff --git a/src/host/layer23/src/modem/grr.c b/src/host/layer23/src/modem/grr.c index cf94695..f0bbf89 100644 --- a/src/host/layer23/src/modem/grr.c +++ b/src/host/layer23/src/modem/grr.c @@ -516,6 +516,10 @@ static void grr_st_packet_idle_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) { struct osmocom_ms *ms = fi->priv; + struct osmo_gprs_rlcmac_prim *prim; + + prim = osmo_gprs_rlcmac_prim_alloc_l1ctl_ccch_ready_ind(); + osmo_gprs_rlcmac_prim_lower_up(prim); modem_gprs_attach_if_needed(ms); } -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/33904 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I05050e840a3b267b3b3a278588ee113b45bfbd4c Gerrit-Change-Number: 33904 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in osmocom-bb[master]: layer23: modem: Delay using cell until fully synced to it
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/33905 ) Change subject: layer23: modem: Delay using cell until fully synced to it ...................................................................... layer23: modem: Delay using cell until fully synced to it Change-Id: If306d82879281bb540c5cdee2eaf354858c8d24b --- M src/host/layer23/include/osmocom/bb/modem/modem.h M src/host/layer23/src/modem/app_modem.c M src/host/layer23/src/modem/grr.c 3 files changed, 51 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/05/33905/1 diff --git a/src/host/layer23/include/osmocom/bb/modem/modem.h b/src/host/layer23/include/osmocom/bb/modem/modem.h index 29d2571..7135bf7 100644 --- a/src/host/layer23/include/osmocom/bb/modem/modem.h +++ b/src/host/layer23/include/osmocom/bb/modem/modem.h @@ -4,6 +4,7 @@ int modem_start(void); int modem_gprs_attach_if_needed(struct osmocom_ms *ms); +int modem_sync_to_cell(struct osmocom_ms *ms); enum modem_state { MODEM_ST_IDLE, diff --git a/src/host/layer23/src/modem/app_modem.c b/src/host/layer23/src/modem/app_modem.c index 6871384..08a1260 100644 --- a/src/host/layer23/src/modem/app_modem.c +++ b/src/host/layer23/src/modem/app_modem.c @@ -165,17 +165,38 @@ return 0; } +int modem_sync_to_cell(struct osmocom_ms *ms) +{ + struct gsm322_cellsel *cs = &ms->cellsel; + + if (cs->sync_pending) { + LOGP(DCS, LOGL_INFO, "Sync to ARFCN=%s, but there is a sync " + "already pending\n", gsm_print_arfcn(cs->arfcn)); + return 0; + } + + cs->sync_pending = true; + l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL); + return l1ctl_tx_fbsb_req(ms, cs->arfcn, + L1CTL_FBSB_F_FB01SB, 100, 0, + cs->ccch_mode, dbm2rxlev(-85)); +} + static int global_signal_cb(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data) { struct osmocom_ms *ms; + struct gsm322_cellsel *cs; + struct osmobb_fbsb_res *fr; if (subsys != SS_L1CTL) return 0; switch (signal) { case S_L1CTL_RESET: + LOGP(DCS, LOGL_NOTICE, "S_L1CTL_RESET\n"); ms = signal_data; + ms->cellsel.arfcn = ms->test_arfcn; if (ms->started) break; layer3_app_reset(); @@ -196,6 +217,22 @@ return l1ctl_tx_fbsb_req(ms, ms->test_arfcn, L1CTL_FBSB_F_FB01SB, 100, 0, CCCH_MODE_NONE, dbm2rxlev(-85)); + case S_L1CTL_FBSB_RESP: + LOGP(DCS, LOGL_NOTICE, "S_L1CTL_FBSB_RESP\n"); + fr = signal_data; + ms = fr->ms; + cs = &ms->cellsel; + cs->sync_pending = false; + break; + case S_L1CTL_FBSB_ERR: + LOGP(DCS, LOGL_NOTICE, "S_L1CTL_FBSB_ERR\n"); + fr = signal_data; + ms = fr->ms; + cs = &ms->cellsel; + cs->sync_pending = false; + /* Retry: */ + modem_sync_to_cell(ms); + break; } return 0; diff --git a/src/host/layer23/src/modem/grr.c b/src/host/layer23/src/modem/grr.c index f0bbf89..2047eef 100644 --- a/src/host/layer23/src/modem/grr.c +++ b/src/host/layer23/src/modem/grr.c @@ -482,6 +482,9 @@ const struct gsm322_cellsel *cs = &ms->cellsel; const struct gsm48_sysinfo *si = &cs->sel_si; + if (cs->sync_pending) /* FBSB in process */ + return false; + if (!si->si1 || !si->si3 || !si->si4 || !si->si13) return false; if (!si->gprs.supported) @@ -684,10 +687,7 @@ handle_pdch_block_ind(ms, (struct msgb *)data); break; case GRR_EV_PDCH_RELEASE_REQ: - l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL); - l1ctl_tx_fbsb_req(ms, ms->test_arfcn, - L1CTL_FBSB_F_FB01SB, 100, 0, - ms->cellsel.ccch_mode, dbm2rxlev(-85)); + modem_sync_to_cell(ms); osmo_fsm_inst_state_chg(fi, GRR_ST_PACKET_IDLE, 0, 0); break; default: -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/33905 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: If306d82879281bb540c5cdee2eaf354858c8d24b Gerrit-Change-Number: 33905 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in libosmo-gprs[master]: rlcmac: ul_tbf: Move logic selecting proper queue to helper function
by osmith 24 Jul '23

24 Jul '23
Attention is currently required from: pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/33888 ) Change subject: rlcmac: ul_tbf: Move logic selecting proper queue to helper function ...................................................................... Patch Set 2: Code-Review+1 (1 comment) File src/rlcmac/tbf_ul.c: https://gerrit.osmocom.org/c/libosmo-gprs/+/33888/comment/5a3a4bc2_aabd96d8 PS1, Line 331: /* Returns the MS/GRE queue unless the UL TBF has entered Countdown Procedure. In that case, it returns the specific frozen queue. */ > very long line Done -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/33888 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Icceaf53048e9662176385b2976e2bc8e3387df71 Gerrit-Change-Number: 33888 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 24 Jul 2023 11:59:16 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Comment-In-Reply-To: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmo-gprs[master]: rlcmac: Apply tx_cs requested by the network through PKT UL ACK/NACK
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/33899 ) Change subject: rlcmac: Apply tx_cs requested by the network through PKT UL ACK/NACK ...................................................................... rlcmac: Apply tx_cs requested by the network through PKT UL ACK/NACK Recalculating CV when in Countdown Procedure will be implemented in a follow-up commit. Related: OS#6108 Change-Id: I1e7b28c2e5f1d77a962ec3070f3a027b8f66a69e --- M src/rlcmac/tbf_ul.c M tests/rlcmac/rlcmac_prim_test.c 2 files changed, 28 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/99/33899/1 diff --git a/src/rlcmac/tbf_ul.c b/src/rlcmac/tbf_ul.c index 6957658..0fa98ae 100644 --- a/src/rlcmac/tbf_ul.c +++ b/src/rlcmac/tbf_ul.c @@ -234,6 +234,18 @@ return 0; } +static void gprs_rlcmac_ul_tbf_update_tx_cs(struct gprs_rlcmac_ul_tbf *ul_tbf, enum gprs_rlcmac_coding_scheme tx_cs) +{ + if (ul_tbf->tx_cs == tx_cs) + return; + + LOGPTBFUL(ul_tbf, LOGL_INFO, "Tx CS update: %s -> %s\n", + gprs_rlcmac_mcs_name(ul_tbf->tx_cs), gprs_rlcmac_mcs_name(tx_cs)); + ul_tbf->tx_cs = tx_cs; + + /* TODO: recalculate countdown_state, have to look a TS 44.060 specs on what to do exactly. */ +} + int gprs_rlcmac_ul_tbf_handle_pkt_ul_ack_nack(struct gprs_rlcmac_ul_tbf *ul_tbf, const RlcMacDownlink_t *dl_block) { @@ -276,6 +288,8 @@ "Received acknowledge of all blocks, but without final ack indication (don't worry)\n"); } + gprs_rlcmac_ul_tbf_update_tx_cs(ul_tbf, gprs->CHANNEL_CODING_COMMAND + GPRS_RLCMAC_CS_1); + return rc; } diff --git a/tests/rlcmac/rlcmac_prim_test.c b/tests/rlcmac/rlcmac_prim_test.c index 0c40737..10f148a 100644 --- a/tests/rlcmac/rlcmac_prim_test.c +++ b/tests/rlcmac/rlcmac_prim_test.c @@ -321,7 +321,7 @@ ack->UPLINK_TFI = ul_tfi; ack->UnionType = 0; /* GPRS */ - gprs->CHANNEL_CODING_COMMAND = cs; + gprs->CHANNEL_CODING_COMMAND = gprs_rlcmac_mcs_chan_code(cs); } static void ul_ack_nack_mark(Ack_Nack_Description_t *ack_desc, unsigned int idx, bool received) -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/33899 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I1e7b28c2e5f1d77a962ec3070f3a027b8f66a69e Gerrit-Change-Number: 33899 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in libosmo-gprs[master]: rlcmac: ul_tbf: Move logic selecting proper queue to helper function
by pespin 24 Jul '23

24 Jul '23
Attention is currently required from: pespin. Hello osmith, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmo-gprs/+/33888 to look at the new patch set (#2). Change subject: rlcmac: ul_tbf: Move logic selecting proper queue to helper function ...................................................................... rlcmac: ul_tbf: Move logic selecting proper queue to helper function This clarifies the logic behind selecting the proper queue, and it will be used further in the future, for instance when recalculating CV once already in Countdown procedure. Change-Id: Icceaf53048e9662176385b2976e2bc8e3387df71 --- M src/rlcmac/tbf_ul.c 1 file changed, 26 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/88/33888/2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/33888 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Icceaf53048e9662176385b2976e2bc8e3387df71 Gerrit-Change-Number: 33888 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in libosmo-gprs[master]: rlcmac: recalculate CV as needed when already in Countdown procedure
by pespin 24 Jul '23

24 Jul '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/33900 ) Change subject: rlcmac: recalculate CV as needed when already in Countdown procedure ...................................................................... rlcmac: recalculate CV as needed when already in Countdown procedure Getting out of contention resolution means we may have to update our calculated CV state because we are no longer sending TLLI. Same happens if a new tx CS is provided by the network, since different block size means different CV. In this commit only code paths for the state where already in Countdown Procedure are added. If TBF has to enter Countdown Procedure due the above mentioned changes, it will do so using regular path where a new RLC block is created. Related specs: TS 44.060 9.3.1 Related: OS#6018 Change-Id: Ifa2f8415918c10dfc10d23f6ea9bcc47172cd9f0 Change-Id: I6ca88c005060ba1302d46717e45b0d9731d86d8d --- M include/osmocom/gprs/rlcmac/tbf_ul.h M src/rlcmac/tbf_ul.c M src/rlcmac/tbf_ul_fsm.c 3 files changed, 84 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/00/33900/1 diff --git a/include/osmocom/gprs/rlcmac/tbf_ul.h b/include/osmocom/gprs/rlcmac/tbf_ul.h index 660cf5a..fe9db64 100644 --- a/include/osmocom/gprs/rlcmac/tbf_ul.h +++ b/include/osmocom/gprs/rlcmac/tbf_ul.h @@ -52,6 +52,8 @@ struct gprs_rlcmac_ul_tbf *gprs_rlcmac_ul_tbf_alloc(struct gprs_rlcmac_entity *gre); void gprs_rlcmac_ul_tbf_free(struct gprs_rlcmac_ul_tbf *ul_tbf); +void gprs_rlcmac_ul_tbf_countdown_proc_update_cv(struct gprs_rlcmac_ul_tbf *ul_tbf); + bool gprs_rlcmac_ul_tbf_in_contention_resolution(const struct gprs_rlcmac_ul_tbf *ul_tbf); unsigned int gprs_rlcmac_ul_tbf_n3104_max(const struct gprs_rlcmac_ul_tbf *ul_tbf); bool gprs_rlcmac_ul_tbf_have_data(const struct gprs_rlcmac_ul_tbf *ul_tbf); diff --git a/src/rlcmac/tbf_ul.c b/src/rlcmac/tbf_ul.c index 0fa98ae..369be55 100644 --- a/src/rlcmac/tbf_ul.c +++ b/src/rlcmac/tbf_ul.c @@ -243,7 +243,13 @@ gprs_rlcmac_mcs_name(ul_tbf->tx_cs), gprs_rlcmac_mcs_name(tx_cs)); ul_tbf->tx_cs = tx_cs; - /* TODO: recalculate countdown_state, have to look a TS 44.060 specs on what to do exactly. */ + /* TS 44.060 9.3.1.2: If in Countdown Procedure state, CV needs to be + * recalculated since CS change means also block size change and hence + * the new CV != old CV (new CV may be greater or lesser than old CV). + * This means CV can go back to 15, but still be in Countdown Procedure, + * aka no new enqueued LLC data in the MS is to be transmitted until the + * current TBF finishes. */ + gprs_rlcmac_ul_tbf_countdown_proc_update_cv(ul_tbf); } int gprs_rlcmac_ul_tbf_handle_pkt_ul_ack_nack(struct gprs_rlcmac_ul_tbf *ul_tbf, @@ -517,7 +523,7 @@ static uint8_t gprs_rlcmac_ul_tbf_calculate_cv(const struct gprs_rlcmac_ul_tbf *ul_tbf) { struct blk_count_state st; - const struct gprs_rlcmac_llc_queue *q = ul_tbf->tbf.gre->llc_queue; + const struct gprs_rlcmac_llc_queue *q = gprs_rlcmac_ul_tbf_llc_queue(ul_tbf); unsigned int i, j; unsigned x; @@ -572,11 +578,22 @@ ul_tbf->tbf.gre->llc_queue = gprs_rlcmac_llc_queue_alloc(ul_tbf->tbf.gre); } -static void gprs_rlcmac_ul_tbf_check_countdown_proc(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_rts_block_ind *bi) +/* Check if UL TBF needs to enter Countdown Procedure everytime a new RLC/MAC block is to be transmitted */ +static void gprs_rlcmac_ul_tbf_countdown_proc_check_enter(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_rts_block_ind *bi) { - if (ul_tbf->countdown_proc.active) + if (ul_tbf->countdown_proc.active) { + /* This may happen if TBF entered Countdown Procedure state but + * later on due to CS change the CV incremented to more than BS_CV_MAX. + * In this case we cannot simply decrement the CV each time a + * new block is transmitted, but we rather need to keep + * calculating it here: + */ + if (ul_tbf->countdown_proc.cv == 15) + ul_tbf->countdown_proc.cv = gprs_rlcmac_ul_tbf_calculate_cv(ul_tbf); return; + } + /* Not (yet) in Countdown Procedure, check if we need to enter into it */ ul_tbf->countdown_proc.cv = gprs_rlcmac_ul_tbf_calculate_cv(ul_tbf); if (ul_tbf->countdown_proc.cv < 15) { if (gprs_rlcmac_ul_tbf_shall_keep_open(ul_tbf, bi)) { @@ -590,6 +607,18 @@ } } +/* Recalculate CV once in Countdown Procedure if conditions change (called by): + * - If contention resolution succeeds + * - If tx CS requested by network changes + */ +void gprs_rlcmac_ul_tbf_countdown_proc_update_cv(struct gprs_rlcmac_ul_tbf *ul_tbf) +{ + + if (!ul_tbf->countdown_proc.active) + return; + ul_tbf->countdown_proc.cv = gprs_rlcmac_ul_tbf_calculate_cv(ul_tbf); +} + static int create_new_bsn(struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_rts_block_ind *bi, enum gprs_rlcmac_coding_scheme cs) { const uint16_t bsn = gprs_rlcmac_rlc_ul_window_v_s(ul_tbf->ulw); @@ -600,7 +629,7 @@ int write_offset = 0; enum gpr_rlcmac_append_result ar; - gprs_rlcmac_ul_tbf_check_countdown_proc(ul_tbf, bi); + gprs_rlcmac_ul_tbf_countdown_proc_check_enter(ul_tbf, bi); if (!ul_tbf->llc_tx_msg || msgb_length(ul_tbf->llc_tx_msg) == 0) gprs_rlcmac_ul_tbf_schedule_next_llc_frame(ul_tbf); @@ -628,10 +657,17 @@ rdbi->data_len = block_data_len; rdbi->ti = gprs_rlcmac_ul_tbf_in_contention_resolution(ul_tbf); - rdbi->cv = ul_tbf->countdown_proc.cv--; + rdbi->cv = ul_tbf->countdown_proc.cv; rdbi->bsn = bsn; /* Block Sequence Number */ rdbi->e = 1; /* Extension bit, maybe set later (1: no extension) */ + /* Once we enter countdown procedure, simply decrement the counter to + * avoid recalculating all the time. */ + if (ul_tbf->countdown_proc.cv < 15) + ul_tbf->countdown_proc.cv--; + /* else: It will be updated in next call to + gprs_rlcmac_ul_tbf_countdown_proc_check_enter() above */ + if (rdbi->ti) { /* Append TLLI: */ if (gprs_rlcmac_mcs_is_gprs(cs)) diff --git a/src/rlcmac/tbf_ul_fsm.c b/src/rlcmac/tbf_ul_fsm.c index 2265aa4..7639d83 100644 --- a/src/rlcmac/tbf_ul_fsm.c +++ b/src/rlcmac/tbf_ul_fsm.c @@ -127,6 +127,20 @@ } } +static void _contention_resolution_succeeded(struct gprs_rlcmac_tbf_ul_fsm_ctx *ctx) +{ + LOGPFSML(ctx->fi, LOGL_INFO, "Contention resolution succeeded, stop T3166\n"); + OSMO_ASSERT(ctx->ul_tbf->ul_ass_fsm.ass_type == GPRS_RLCMAC_TBF_UL_ASS_TYPE_1PHASE); + OSMO_ASSERT(ctx->fi->T == 3166); + osmo_timer_del(&ctx->fi->timer); + ctx->fi->T = 0; + + /* TS 44.060 9.3.1.2: If in Countdown Procedure state, CV needs to be recalculated + * since TBF is no longer transmitting TLLI in the block, hence 4 more bytes per + * block are available. This means the new CV <= old CV. */ + gprs_rlcmac_ul_tbf_countdown_proc_update_cv(ctx->ul_tbf); +} + /* This one is triggered when packet access procedure fails, which can happen * either in WAIT_IMM_ASS (ImmAss timeout), FLOW (T3164) or FINISHED (T3164, T3166) */ static void st_new_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) @@ -195,11 +209,7 @@ break; case GPRS_RLCMAC_TBF_UL_EV_RX_UL_ACK_NACK: if (gprs_rlcmac_ul_tbf_in_contention_resolution(ctx->ul_tbf)) { - LOGPFSML(ctx->fi, LOGL_INFO, "Contention resolution succeeded, stop T3166\n"); - OSMO_ASSERT(ctx->ul_tbf->ul_ass_fsm.ass_type == GPRS_RLCMAC_TBF_UL_ASS_TYPE_1PHASE); - OSMO_ASSERT(fi->T == 3166); - osmo_timer_del(&fi->timer); - fi->T = 0; + _contention_resolution_succeeded(ctx); } /* It's impossible we receive a correct final_ack here, since we didn't * sent last data (FSM would be in FINISHED state then) */ @@ -224,11 +234,7 @@ case GPRS_RLCMAC_TBF_UL_EV_RX_UL_ACK_NACK: ctx_ul_ack_nack = (struct tbf_ul_ass_ev_rx_ul_ack_nack *)data; if (gprs_rlcmac_ul_tbf_in_contention_resolution(ctx->ul_tbf)) { - LOGPFSML(ctx->fi, LOGL_INFO, "Contention resolution succeeded, stop T3166\n"); - OSMO_ASSERT(ctx->ul_tbf->ul_ass_fsm.ass_type == GPRS_RLCMAC_TBF_UL_ASS_TYPE_1PHASE); - OSMO_ASSERT(fi->T == 3166); - osmo_timer_del(&fi->timer); - fi->T = 0; + _contention_resolution_succeeded(ctx); } else if (fi->T == 3182 && osmo_timer_pending(&fi->timer)) { /* 9.3.3.3.2 "Upon reception of a PACKET UPLINK ACK/NACK message for this TBF * the mobile station shall stop timer T3182 for the TBF". -- To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/33900 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I6ca88c005060ba1302d46717e45b0d9731d86d8d Gerrit-Change-Number: 33900 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • ...
  • 306
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.