From d2c862a84940452407344de9eddb3af4ca85abd1 Mon Sep 17 00:00:00 2001 From: "Andreas.Eversberg" Date: Wed, 29 Sep 2010 13:24:12 +0000 Subject: [PATCH] [layer23] Disabled may debugging in cell selection process This way the syncing and cell selection can be reviewed much better. --- src/host/layer23/src/mobile/gsm322.c | 66 +++++++++++++++++++++------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c index cdb8d1a5c..126cdfc08 100644 --- a/src/host/layer23/src/mobile/gsm322.c +++ b/src/host/layer23/src/mobile/gsm322.c @@ -45,6 +45,8 @@ static void gsm322_cs_loss(void *arg); static int gsm322_cs_select(struct osmocom_ms *ms, int any, int plmn_allowed); static int gsm322_m_switch_on(struct osmocom_ms *ms, struct msgb *msg); +//#define CS_HEAVY_DEBUG + #warning HACKING!!! int hack; @@ -235,18 +237,23 @@ static int gsm322_sync_to_cell(struct gsm322_cellsel *cs) struct osmocom_ms *ms = cs->ms; struct gsm48_sysinfo *s = cs->si; - LOGP(DCS, LOGL_INFO, "Start syncing. (ARFCN=%d)\n", cs->arfcn); cs->ccch_state = GSM322_CCCH_ST_INIT; - if (s) { + if (s && s->si3) { if (s->ccch_conf == 1) { - LOGP(DCS, LOGL_INFO, "Sysinfo, ccch mode COMB\n"); + LOGP(DCS, LOGL_INFO, "Sync to ARFCN=%d rxlev=%s " + "(Sysinfo, ccch mode COMB)\n", cs->arfcn, + gsm_print_rxlev(cs->list[cs->arfcn].rxlev)); cs->ccch_mode = CCCH_MODE_COMBINED; } else { - LOGP(DCS, LOGL_INFO, "Sysinfo, ccch mode NON-COMB\n"); + LOGP(DCS, LOGL_INFO, "Sync to ARFCN=%d rxlev=%s " + "(Sysinfo, ccch mode NON-COMB)\n", cs->arfcn, + gsm_print_rxlev(cs->list[cs->arfcn].rxlev)); cs->ccch_mode = CCCH_MODE_NON_COMBINED; } } else { - LOGP(DCS, LOGL_INFO, "No sysinfo, ccch mode NONE\n"); + LOGP(DCS, LOGL_INFO, "Sync to ARFCN=%d rxlev=%s (No sysinfo " + "yet, ccch mode NONE)\n", cs->arfcn, + gsm_print_rxlev(cs->list[cs->arfcn].rxlev)); cs->ccch_mode = CCCH_MODE_NONE; } @@ -430,7 +437,9 @@ static void stop_plmn_timer(struct gsm322_plmn *plmn) /* start cell selection timer */ void start_cs_timer(struct gsm322_cellsel *cs, int sec, int micro) { +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Starting CS timer with %d seconds.\n", sec); +#endif cs->timer.cb = gsm322_cs_timeout; cs->timer.data = cs; bsc_schedule_timer(&cs->timer, sec, micro); @@ -456,7 +465,9 @@ void start_loss_timer(struct gsm322_cellsel *cs, int sec, int micro) return; } +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Starting loss CS timer with %d seconds.\n", sec); +#endif bsc_schedule_timer(&cs->timer, sec, micro); } @@ -464,7 +475,9 @@ void start_loss_timer(struct gsm322_cellsel *cs, int sec, int micro) static void stop_cs_timer(struct gsm322_cellsel *cs) { if (bsc_timer_pending(&cs->timer)) { +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "stopping pending CS timer.\n"); +#endif bsc_del_timer(&cs->timer); } } @@ -1513,11 +1526,15 @@ static int gsm322_cs_select(struct osmocom_ms *ms, int any, int plmn_allowed) /* set out access class depending on the cell selection type */ if (any) { acc_class = subscr->acc_class | 0x0400; /* add emergency */ +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Select using access class with Emergency " "class.\n"); +#endif } else { acc_class = subscr->acc_class; +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Select using access class \n"); +#endif } /* flags to match */ @@ -1703,7 +1720,6 @@ static int gsm322_cs_scan(struct osmocom_ms *ms) gsm_print_rxlev(cs->list[cs->arfcn].rxlev)); hack = 1; gsm322_sync_to_cell(cs); -// start_cs_timer(cs, ms->support.sync_to, 0); return 0; } @@ -1796,11 +1812,12 @@ static int gsm322_cs_scan(struct osmocom_ms *ms) /* Tune to frequency for a while, to receive broadcasts. */ cs->arfcn = weight & 1023; +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Scanning frequency %d (rxlev %s).\n", cs->arfcn, gsm_print_rxlev(cs->list[cs->arfcn].rxlev)); +#endif hack = 1; gsm322_sync_to_cell(cs); -// start_cs_timer(cs, ms->support.sync_to, 0); /* Allocate/clean system information. */ cs->list[cs->arfcn].flags &= ~GSM322_CS_FLAG_SYSINFO; @@ -1816,9 +1833,11 @@ static int gsm322_cs_scan(struct osmocom_ms *ms) /* increase scan counter for each maximum scan range */ if (gsm_sup_smax[j].max) { +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "%d frequencies left in band %d..%d\n", gsm_sup_smax[j].max - gsm_sup_smax[j].temp, gsm_sup_smax[j].start, gsm_sup_smax[j].end); +#endif gsm_sup_smax[j].temp++; } @@ -1877,10 +1896,12 @@ static int gsm322_cs_store(struct osmocom_ms *ms) cs->list[cs->arfcn].flags &= ~GSM322_CS_FLAG_FORBIDD; } +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Scan frequency %d: Cell found. (rxlev %s " "mcc %s mnc %s lac %04x)\n", cs->arfcn, gsm_print_rxlev(cs->list[cs->arfcn].rxlev), gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc), s->lac); +#endif /* special case for PLMN search */ if (cs->state == GSM322_PLMN_SEARCH) @@ -2192,7 +2213,9 @@ static int gsm322_c_scan_sysinfo_bcch(struct osmocom_ms *ms, struct msgb *msg) || (s->si2bis && s->nb_ext_ind_si2 && !s->nb_ext_ind_si2bis) || (s->si2bis && s->si2ter && s->nb_ext_ind_si2 && s->nb_ext_ind_si2bis))) { +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Received relevant sysinfo.\n"); +#endif /* stop timer */ stop_cs_timer(cs); @@ -2211,21 +2234,18 @@ static void gsm322_cs_timeout(void *arg) struct gsm322_cellsel *cs = arg; struct osmocom_ms *ms = cs->ms; - LOGP(DCS, LOGL_INFO, "Cell selection failed.\n"); - /* if we have no lock, we retry */ if (cs->ccch_state != GSM322_CCCH_ST_SYNC) - LOGP(DCS, LOGL_INFO, "Sync timeout.\n"); + LOGP(DCS, LOGL_INFO, "Cell selection failed, sync timeout.\n"); else - LOGP(DCS, LOGL_INFO, "Read timeout.\n"); - - LOGP(DCS, LOGL_INFO, "Scan frequency %d: Cell not found. (rxlev %s)\n", - cs->arfcn, gsm_print_rxlev(cs->list[cs->arfcn].rxlev)); + LOGP(DCS, LOGL_INFO, "Cell selection failed, read timeout.\n"); /* remove system information */ cs->list[cs->arfcn].flags &= ~GSM322_CS_FLAG_SYSINFO; if (cs->list[cs->arfcn].sysinfo) { +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "free sysinfo arfcn=%d\n", cs->arfcn); +#endif talloc_free(cs->list[cs->arfcn].sysinfo); cs->list[cs->arfcn].sysinfo = NULL; gsm322_unselect_cell(cs); @@ -2256,7 +2276,9 @@ static int gsm322_cs_powerscan(struct osmocom_ms *ms) /* in case of sticking to a cell, we only select it */ if (set->stick) { +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_FATAL, "Scanning power for sticked cell.\n"); +#endif i = set->stick_arfcn; if ((cs->list[i].flags & mask) == flags) s = e = i; @@ -2264,13 +2286,18 @@ static int gsm322_cs_powerscan(struct osmocom_ms *ms) /* search for first frequency to scan */ if (cs->state == GSM322_C2_STORED_CELL_SEL || cs->state == GSM322_C5_CHOOSE_CELL) { +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_FATAL, "Scanning power for stored BA " "list.\n"); +#endif mask |= GSM322_CS_FLAG_BA; flags |= GSM322_CS_FLAG_BA; - } else + } +#ifdef CS_HEAVY_DEBUG + else LOGP(DCS, LOGL_FATAL, "Scanning power for all " "frequencies.\n"); +#endif for (i = 0; i <= 1023; i++) { if ((cs->list[i].flags & mask) == flags) { s = e = i; @@ -2343,7 +2370,6 @@ static int gsm322_cs_powerscan(struct osmocom_ms *ms) cs->list[cs->arfcn].rxlev)); hack = 1; gsm322_sync_to_cell(cs); -// start_cs_timer(cs, ms->support.sync_to, 0); } else new_c_state(cs, GSM322_C0_NULL); @@ -2369,7 +2395,9 @@ static int gsm322_cs_powerscan(struct osmocom_ms *ms) } } +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Scanning frequencies. (%d..%d)\n", s, e); +#endif /* start scan on radio interface */ if (!cs->powerscan) { @@ -2415,7 +2443,9 @@ static int gsm322_l1_signal(unsigned int subsys, unsigned int signal, } break; case S_L1CTL_PM_DONE: +#ifdef CS_HEAVY_DEBUG LOGP(DCS, LOGL_INFO, "Done with power scanning range.\n"); +#endif ms = signal_data; cs = &ms->cellsel; if (!cs->powerscan) @@ -2456,14 +2486,16 @@ static int gsm322_l1_signal(unsigned int subsys, unsigned int signal, } break; case S_L1CTL_FBSB_ERR: +#if 0 if (hack) { ms = signal_data; cs = &ms->cellsel; gsm322_sync_to_cell(cs); hack--; - LOGP(DCS, LOGL_INFO, "Channel sync error, try again.\n"); + LOGP(DCS, LOGL_INFO, "Channel sync error, try again\n"); break; } +#endif LOGP(DCS, LOGL_INFO, "Channel sync error.\n"); ms = signal_data; cs = &ms->cellsel;