1 /* Layer1 control code, talking L1CTL protocol with L1 on the phone */
3 /* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * (C) 2010 by Harald Welte <laforge@gnumonks.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <arpa/inet.h>
31 #include <l1ctl_proto.h>
33 #include <osmocom/core/signal.h>
34 #include <osmocom/core/logging.h>
35 #include <osmocom/core/timer.h>
36 #include <osmocom/core/msgb.h>
37 #include <osmocom/gsm/tlv.h>
38 #include <osmocom/gsm/gsm_utils.h>
39 #include <osmocom/core/gsmtap_util.h>
40 #include <osmocom/gsm/protocol/gsm_04_08.h>
41 #include <osmocom/gsm/protocol/gsm_08_58.h>
42 #include <osmocom/gsm/rsl.h>
44 #include <osmocom/bb/common/l1ctl.h>
45 #include <osmocom/bb/common/osmocom_data.h>
46 #include <osmocom/bb/common/l1l2_interface.h>
47 #include <osmocom/bb/common/lapdm.h>
48 #include <osmocom/bb/common/logging.h>
50 extern struct gsmtap_inst *gsmtap_inst;
52 static struct msgb *osmo_l1_alloc(uint8_t msg_type)
54 struct l1ctl_hdr *l1h;
55 struct msgb *msg = msgb_alloc_headroom(256, 4, "osmo_l1");
58 LOGP(DL1C, LOGL_ERROR, "Failed to allocate memory.\n");
62 msg->l1h = msgb_put(msg, sizeof(*l1h));
63 l1h = (struct l1ctl_hdr *) msg->l1h;
64 l1h->msg_type = msg_type;
70 static int osmo_make_band_arfcn(struct osmocom_ms *ms, uint16_t arfcn)
72 /* TODO: Include the band */
76 static int rx_l1_fbsb_conf(struct osmocom_ms *ms, struct msgb *msg)
78 struct l1ctl_info_dl *dl;
79 struct l1ctl_fbsb_conf *sb;
81 struct osmobb_fbsb_res fr;
83 if (msgb_l3len(msg) < sizeof(*dl) + sizeof(*sb)) {
84 LOGP(DL1C, LOGL_ERROR, "FBSB RESP: MSG too short %u\n",
89 dl = (struct l1ctl_info_dl *) msg->l1h;
90 sb = (struct l1ctl_fbsb_conf *) dl->payload;
92 LOGP(DL1C, LOGL_INFO, "snr=%04x, arfcn=%u result=%u\n", dl->snr,
93 ntohs(dl->band_arfcn), sb->result);
95 if (sb->result != 0) {
96 LOGP(DL1C, LOGL_ERROR, "FBSB RESP: result=%u\n", sb->result);
97 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_FBSB_ERR, ms);
101 gsm_fn2gsmtime(&tm, ntohl(dl->frame_nr));
102 DEBUGP(DL1C, "SCH: SNR: %u TDMA: (%.4u/%.2u/%.2u) bsic: %d\n",
103 dl->snr, tm.t1, tm.t2, tm.t3, sb->bsic);
107 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_FBSB_RESP, &fr);
112 static int rx_l1_rach_conf(struct osmocom_ms *ms, struct msgb *msg)
114 struct l1ctl_info_dl *dl;
116 if (msgb_l2len(msg) < sizeof(*dl)) {
117 LOGP(DL1C, LOGL_ERROR, "RACH CONF: MSG too short %u\n",
123 dl = (struct l1ctl_info_dl *) msg->l1h;
125 l2_ph_chan_conf(msg, ms, dl);
130 /* Receive L1CTL_DATA_IND (Data Indication from L1) */
131 static int rx_ph_data_ind(struct osmocom_ms *ms, struct msgb *msg)
133 struct l1ctl_info_dl *dl, dl_cpy;
134 struct l1ctl_data_ind *ccch;
135 struct lapdm_entity *le;
136 struct rx_meas_stat *meas = &ms->meas;
137 uint8_t chan_type, chan_ts, chan_ss;
138 uint8_t gsmtap_chan_type;
141 if (msgb_l3len(msg) < sizeof(*ccch)) {
142 LOGP(DL1C, LOGL_ERROR, "MSG too short Data Ind: %u\n",
148 dl = (struct l1ctl_info_dl *) msg->l1h;
149 msg->l2h = dl->payload;
150 ccch = (struct l1ctl_data_ind *) msg->l2h;
152 gsm_fn2gsmtime(&tm, ntohl(dl->frame_nr));
153 rsl_dec_chan_nr(dl->chan_nr, &chan_type, &chan_ss, &chan_ts);
154 DEBUGP(DL1C, "%s (%.4u/%.2u/%.2u) %d dBm: %s\n",
155 rsl_chan_nr_str(dl->chan_nr), tm.t1, tm.t2, tm.t3,
156 (int)dl->rx_level-110,
157 osmo_hexdump(ccch->data, sizeof(ccch->data)));
159 meas->last_fn = ntohl(dl->frame_nr);
161 meas->snr += dl->snr;
162 meas->berr += dl->num_biterr;
163 meas->rxlev += dl->rx_level;
165 /* counting loss criteria */
166 if (!(dl->link_id & 0x40)) {
168 case RSL_CHAN_PCH_AGCH:
171 if (dl->fire_crc >= 2)
175 if (meas->dsc > meas->ds_fail)
176 meas->dsc = meas->ds_fail;
177 if (meas->dsc < meas->ds_fail)
178 printf("LOSS counter for CCCH %d\n", meas->dsc);
182 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_LOSS_IND, ms);
187 case RSL_CHAN_Bm_ACCHs:
188 case RSL_CHAN_Lm_ACCHs:
189 case RSL_CHAN_SDCCH4_ACCH:
190 case RSL_CHAN_SDCCH8_ACCH:
193 if (dl->fire_crc >= 2)
197 if (meas->s > meas->rl_fail)
198 meas->s = meas->rl_fail;
199 if (meas->s < meas->rl_fail)
200 printf("LOSS counter for ACCH %d\n", meas->s);
204 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_LOSS_IND, ms);
209 if (dl->fire_crc >= 2) {
210 printf("Dropping frame with %u bit errors\n", dl->num_biterr);
211 LOGP(DL1C, LOGL_NOTICE, "Dropping frame with %u bit errors\n",
217 /* send CCCH data via GSMTAP */
218 gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, dl->link_id);
219 gsmtap_send(gsmtap_inst, ntohs(dl->band_arfcn), chan_ts,
220 gsmtap_chan_type, chan_ss, tm.fn, dl->rx_level-110,
221 dl->snr, ccch->data, sizeof(ccch->data));
223 /* determine LAPDm entity based on SACCH or not */
224 if (dl->link_id & 0x40)
225 le = &ms->l2_entity.lapdm_acch;
227 le = &ms->l2_entity.lapdm_dcch;
228 /* make local stack copy of l1ctl_info_dl, as LAPDm will
229 * overwrite skb hdr */
230 memcpy(&dl_cpy, dl, sizeof(dl_cpy));
232 /* pull the L1 header from the msgb */
233 msgb_pull(msg, msg->l2h - (msg->l1h-sizeof(struct l1ctl_hdr)));
236 /* send it up into LAPDm */
237 l2_ph_data_ind(msg, le, &dl_cpy);
242 /* Receive L1CTL_DATA_CONF (Data Confirm from L1) */
243 static int rx_ph_data_conf(struct osmocom_ms *ms, struct msgb *msg)
245 struct l1ctl_info_dl *dl;
246 struct lapdm_entity *le;
248 dl = (struct l1ctl_info_dl *) msg->l1h;
250 /* determine LAPDm entity based on SACCH or not */
251 if (dl->link_id & 0x40)
252 le = &ms->l2_entity.lapdm_acch;
254 le = &ms->l2_entity.lapdm_dcch;
256 /* send it up into LAPDm */
257 l2_ph_data_conf(msg, le);
262 /* Transmit L1CTL_DATA_REQ */
263 int l1ctl_tx_data_req(struct osmocom_ms *ms, struct msgb *msg,
264 uint8_t chan_nr, uint8_t link_id)
266 struct l1ctl_hdr *l1h;
267 struct l1ctl_info_ul *l1i_ul;
268 uint8_t chan_type, chan_ts, chan_ss;
269 uint8_t gsmtap_chan_type;
271 DEBUGP(DL1C, "(%s)\n", osmo_hexdump(msg->l2h, msgb_l2len(msg)));
273 if (msgb_l2len(msg) > 23) {
274 LOGP(DL1C, LOGL_ERROR, "L1 cannot handle message length "
275 "> 23 (%u)\n", msgb_l2len(msg));
278 } else if (msgb_l2len(msg) < 23)
279 LOGP(DL1C, LOGL_ERROR, "L1 message length < 23 (%u) "
280 "doesn't seem right!\n", msgb_l2len(msg));
282 /* send copy via GSMTAP */
283 rsl_dec_chan_nr(chan_nr, &chan_type, &chan_ss, &chan_ts);
284 gsmtap_chan_type = chantype_rsl2gsmtap(chan_type, link_id);
285 gsmtap_send(gsmtap_inst, 0|0x4000, chan_ts, gsmtap_chan_type,
286 chan_ss, 0, 127, 255, msg->l2h, msgb_l2len(msg));
288 /* prepend uplink info header */
289 l1i_ul = (struct l1ctl_info_ul *) msgb_push(msg, sizeof(*l1i_ul));
291 l1i_ul->chan_nr = chan_nr;
292 l1i_ul->link_id = link_id;
294 /* prepend l1 header */
295 msg->l1h = msgb_push(msg, sizeof(*l1h));
296 l1h = (struct l1ctl_hdr *) msg->l1h;
297 l1h->msg_type = L1CTL_DATA_REQ;
299 return osmo_send_l1(ms, msg);
302 /* Transmit FBSB_REQ */
303 int l1ctl_tx_fbsb_req(struct osmocom_ms *ms, uint16_t arfcn,
304 uint8_t flags, uint16_t timeout, uint8_t sync_info_idx,
308 struct l1ctl_fbsb_req *req;
310 LOGP(DL1C, LOGL_INFO, "Sync Req\n");
312 msg = osmo_l1_alloc(L1CTL_FBSB_REQ);
316 req = (struct l1ctl_fbsb_req *) msgb_put(msg, sizeof(*req));
317 req->band_arfcn = htons(osmo_make_band_arfcn(ms, arfcn));
318 req->timeout = htons(timeout);
319 /* Threshold when to consider FB_MODE1: 4kHz - 1kHz */
320 req->freq_err_thresh1 = htons(11000 - 1000);
321 /* Threshold when to consider SCH: 1kHz - 200Hz */
322 req->freq_err_thresh2 = htons(1000 - 200);
324 req->num_freqerr_avg = 3;
326 req->sync_info_idx = sync_info_idx;
327 req->ccch_mode = ccch_mode;
329 return osmo_send_l1(ms, msg);
332 /* Transmit L1CTL_CCCH_MODE_REQ */
333 int l1ctl_tx_ccch_mode_req(struct osmocom_ms *ms, uint8_t ccch_mode)
336 struct l1ctl_ccch_mode_req *req;
338 LOGP(DL1C, LOGL_INFO, "CCCH Mode Req\n");
340 msg = osmo_l1_alloc(L1CTL_CCCH_MODE_REQ);
344 req = (struct l1ctl_ccch_mode_req *) msgb_put(msg, sizeof(*req));
345 req->ccch_mode = ccch_mode;
347 return osmo_send_l1(ms, msg);
350 /* Transmit L1CTL_TCH_MODE_REQ */
351 int l1ctl_tx_tch_mode_req(struct osmocom_ms *ms, uint8_t tch_mode)
354 struct l1ctl_tch_mode_req *req;
356 LOGP(DL1C, LOGL_INFO, "TCH Mode Req\n");
358 msg = osmo_l1_alloc(L1CTL_TCH_MODE_REQ);
362 req = (struct l1ctl_tch_mode_req *) msgb_put(msg, sizeof(*req));
363 req->tch_mode = tch_mode;
365 return osmo_send_l1(ms, msg);
368 /* Transmit L1CTL_PARAM_REQ */
369 int l1ctl_tx_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power)
372 struct l1ctl_info_ul *ul;
373 struct l1ctl_par_req *req;
375 msg = osmo_l1_alloc(L1CTL_PARAM_REQ);
379 DEBUGP(DL1C, "PARAM Req. ta=%d, tx_power=%d\n", ta, tx_power);
380 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
381 req = (struct l1ctl_par_req *) msgb_put(msg, sizeof(*req));
382 req->tx_power = tx_power;
385 return osmo_send_l1(ms, msg);
388 /* Transmit L1CTL_CRYPTO_REQ */
389 int l1ctl_tx_crypto_req(struct osmocom_ms *ms, uint8_t algo, uint8_t *key,
393 struct l1ctl_info_ul *ul;
394 struct l1ctl_crypto_req *req;
396 msg = osmo_l1_alloc(L1CTL_CRYPTO_REQ);
400 DEBUGP(DL1C, "CRYPTO Req. algo=%d, len=%d\n", algo, len);
401 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
402 req = (struct l1ctl_crypto_req *) msgb_put(msg, sizeof(*req) + len);
405 memcpy(req->key, key, len);
407 return osmo_send_l1(ms, msg);
410 /* Transmit L1CTL_RACH_REQ */
411 int l1ctl_tx_rach_req(struct osmocom_ms *ms, uint8_t ra, uint16_t offset,
415 struct l1ctl_info_ul *ul;
416 struct l1ctl_rach_req *req;
418 msg = osmo_l1_alloc(L1CTL_RACH_REQ);
422 DEBUGP(DL1C, "RACH Req. offset=%d combined=%d\n", offset, combined);
423 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
424 req = (struct l1ctl_rach_req *) msgb_put(msg, sizeof(*req));
426 req->offset = htons(offset);
427 req->combined = combined;
429 return osmo_send_l1(ms, msg);
432 /* Transmit L1CTL_DM_EST_REQ */
433 int l1ctl_tx_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn,
434 uint8_t chan_nr, uint8_t tsc, uint8_t tch_mode)
437 struct l1ctl_info_ul *ul;
438 struct l1ctl_dm_est_req *req;
440 msg = osmo_l1_alloc(L1CTL_DM_EST_REQ);
444 LOGP(DL1C, LOGL_INFO, "Tx Dedic.Mode Est Req (arfcn=%u, "
445 "chan_nr=0x%02x)\n", band_arfcn, chan_nr);
447 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
448 ul->chan_nr = chan_nr;
451 req = (struct l1ctl_dm_est_req *) msgb_put(msg, sizeof(*req));
454 req->h0.band_arfcn = htons(band_arfcn);
455 req->tch_mode = tch_mode;
457 return osmo_send_l1(ms, msg);
460 int l1ctl_tx_dm_est_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn,
461 uint16_t *ma, uint8_t ma_len,
462 uint8_t chan_nr, uint8_t tsc, uint8_t tch_mode)
465 struct l1ctl_info_ul *ul;
466 struct l1ctl_dm_est_req *req;
469 msg = osmo_l1_alloc(L1CTL_DM_EST_REQ);
473 LOGP(DL1C, LOGL_INFO, "Tx Dedic.Mode Est Req (maio=%u, hsn=%u, "
474 "chan_nr=0x%02x)\n", maio, hsn, chan_nr);
476 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
477 ul->chan_nr = chan_nr;
480 req = (struct l1ctl_dm_est_req *) msgb_put(msg, sizeof(*req));
486 for (i = 0; i < ma_len; i++)
487 req->h1.ma[i] = htons(ma[i]);
488 req->tch_mode = tch_mode;
490 return osmo_send_l1(ms, msg);
493 /* Transmit L1CTL_DM_FREQ_REQ */
494 int l1ctl_tx_dm_freq_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn,
495 uint8_t tsc, uint16_t fn)
498 struct l1ctl_info_ul *ul;
499 struct l1ctl_dm_freq_req *req;
501 msg = osmo_l1_alloc(L1CTL_DM_FREQ_REQ);
505 LOGP(DL1C, LOGL_INFO, "Tx Dedic.Mode Freq Req (arfcn=%u, fn=%d)\n",
508 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
512 req = (struct l1ctl_dm_freq_req *) msgb_put(msg, sizeof(*req));
516 req->h0.band_arfcn = htons(band_arfcn);
518 return osmo_send_l1(ms, msg);
521 int l1ctl_tx_dm_freq_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn,
522 uint16_t *ma, uint8_t ma_len,
523 uint8_t tsc, uint16_t fn)
526 struct l1ctl_info_ul *ul;
527 struct l1ctl_dm_freq_req *req;
530 msg = osmo_l1_alloc(L1CTL_DM_FREQ_REQ);
534 LOGP(DL1C, LOGL_INFO, "Tx Dedic.Mode Freq Req (maio=%u, hsn=%u, "
535 "fn=%d)\n", maio, hsn, fn);
537 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
541 req = (struct l1ctl_dm_freq_req *) msgb_put(msg, sizeof(*req));
548 for (i = 0; i < ma_len; i++)
549 req->h1.ma[i] = htons(ma[i]);
551 return osmo_send_l1(ms, msg);
554 /* Transmit L1CTL_DM_REL_REQ */
555 int l1ctl_tx_dm_rel_req(struct osmocom_ms *ms)
558 struct l1ctl_info_ul *ul;
560 msg = osmo_l1_alloc(L1CTL_DM_REL_REQ);
564 LOGP(DL1C, LOGL_INFO, "Tx Dedic.Mode Rel Req\n");
566 ul = (struct l1ctl_info_ul *) msgb_put(msg, sizeof(*ul));
568 return osmo_send_l1(ms, msg);
571 int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len)
577 msg = osmo_l1_alloc(L1CTL_ECHO_REQ);
581 data = msgb_put(msg, len);
582 for (i = 0; i < len; i++)
585 return osmo_send_l1(ms, msg);
588 int l1ctl_tx_sim_req(struct osmocom_ms *ms, uint8_t *data, uint16_t length)
593 msg = osmo_l1_alloc(L1CTL_SIM_REQ);
597 dat = msgb_put(msg, length);
598 memcpy(dat, data, length);
600 return osmo_send_l1(ms, msg);
603 /* just forward the SIM response to the SIM handler */
604 static int rx_l1_sim_conf(struct osmocom_ms *ms, struct msgb *msg)
606 uint16_t len = msg->len - sizeof(struct l1ctl_hdr);
607 uint8_t *data = msg->data + sizeof(struct l1ctl_hdr);
609 LOGP(DL1C, LOGL_INFO, "SIM %s\n", osmo_hexdump(data, len));
611 /* pull the L1 header from the msgb */
612 msgb_pull(msg, sizeof(struct l1ctl_hdr));
615 sim_apdu_resp(ms, msg);
620 /* Transmit L1CTL_PM_REQ */
621 int l1ctl_tx_pm_req_range(struct osmocom_ms *ms, uint16_t arfcn_from,
625 struct l1ctl_pm_req *pm;
627 msg = osmo_l1_alloc(L1CTL_PM_REQ);
631 LOGP(DL1C, LOGL_INFO, "Tx PM Req (%u-%u)\n", arfcn_from, arfcn_to);
632 pm = (struct l1ctl_pm_req *) msgb_put(msg, sizeof(*pm));
634 pm->range.band_arfcn_from = htons(arfcn_from);
635 pm->range.band_arfcn_to = htons(arfcn_to);
637 return osmo_send_l1(ms, msg);
640 /* Transmit L1CTL_RESET_REQ */
641 int l1ctl_tx_reset_req(struct osmocom_ms *ms, uint8_t type)
644 struct l1ctl_reset *res;
646 msg = osmo_l1_alloc(L1CTL_RESET_REQ);
650 LOGP(DL1C, LOGL_INFO, "Tx Reset Req (%u)\n", type);
651 res = (struct l1ctl_reset *) msgb_put(msg, sizeof(*res));
654 return osmo_send_l1(ms, msg);
657 /* Receive L1CTL_RESET_IND */
658 static int rx_l1_reset(struct osmocom_ms *ms)
660 LOGP(DL1C, LOGL_INFO, "Layer1 Reset indication\n");
661 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_RESET, ms);
666 /* Receive L1CTL_PM_CONF */
667 static int rx_l1_pm_conf(struct osmocom_ms *ms, struct msgb *msg)
669 struct l1ctl_pm_conf *pmr;
671 for (pmr = (struct l1ctl_pm_conf *) msg->l1h;
672 (uint8_t *) pmr < msg->tail; pmr++) {
673 struct osmobb_meas_res mr;
674 DEBUGP(DL1C, "PM MEAS: ARFCN: %4u RxLev: %3d %3d\n",
675 ntohs(pmr->band_arfcn), pmr->pm[0], pmr->pm[1]);
676 mr.band_arfcn = ntohs(pmr->band_arfcn);
677 mr.rx_lev = pmr->pm[0];
679 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_PM_RES, &mr);
684 /* Receive L1CTL_CCCH_MODE_CONF */
685 static int rx_l1_ccch_mode_conf(struct osmocom_ms *ms, struct msgb *msg)
687 struct osmobb_ccch_mode_conf mc;
688 struct l1ctl_ccch_mode_conf *conf;
690 if (msgb_l3len(msg) < sizeof(*conf)) {
691 LOGP(DL1C, LOGL_ERROR, "CCCH MODE CONF: MSG too short %u\n",
696 conf = (struct l1ctl_ccch_mode_conf *) msg->l1h;
698 LOGP(DL1C, LOGL_INFO, "CCCH MODE CONF: mode=%u\n", conf->ccch_mode);
700 mc.ccch_mode = conf->ccch_mode;
702 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_CCCH_MODE_CONF, &mc);
707 /* Receive L1CTL_TCH_MODE_CONF */
708 static int rx_l1_tch_mode_conf(struct osmocom_ms *ms, struct msgb *msg)
710 struct osmobb_tch_mode_conf mc;
711 struct l1ctl_tch_mode_conf *conf;
713 if (msgb_l3len(msg) < sizeof(*conf)) {
714 LOGP(DL1C, LOGL_ERROR, "TCH MODE CONF: MSG too short %u\n",
719 conf = (struct l1ctl_tch_mode_conf *) msg->l1h;
721 LOGP(DL1C, LOGL_INFO, "TCH MODE CONF: mode=%u\n", conf->tch_mode);
723 mc.tch_mode = conf->tch_mode;
725 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_TCH_MODE_CONF, &mc);
730 /* Receive incoming data from L1 using L1CTL format */
731 int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg)
734 struct l1ctl_hdr *l1h;
735 struct l1ctl_info_dl *dl;
737 if (msgb_l2len(msg) < sizeof(*dl)) {
738 LOGP(DL1C, LOGL_ERROR, "Short Layer2 message: %u\n",
744 l1h = (struct l1ctl_hdr *) msg->l1h;
746 /* move the l1 header pointer to point _BEHIND_ l1ctl_hdr,
747 as the l1ctl header is of no interest to subsequent code */
748 msg->l1h = l1h->data;
750 switch (l1h->msg_type) {
751 case L1CTL_FBSB_CONF:
752 rc = rx_l1_fbsb_conf(ms, msg);
756 rc = rx_ph_data_ind(ms, msg);
758 case L1CTL_DATA_CONF:
759 rc = rx_ph_data_conf(ms, msg);
761 case L1CTL_RESET_IND:
762 case L1CTL_RESET_CONF:
763 rc = rx_l1_reset(ms);
767 rc = rx_l1_pm_conf(ms, msg);
768 if (l1h->flags & L1CTL_F_DONE)
769 osmo_signal_dispatch(SS_L1CTL, S_L1CTL_PM_DONE, ms);
772 case L1CTL_RACH_CONF:
773 rc = rx_l1_rach_conf(ms, msg);
775 case L1CTL_CCCH_MODE_CONF:
776 rc = rx_l1_ccch_mode_conf(ms, msg);
779 case L1CTL_TCH_MODE_CONF:
780 rc = rx_l1_tch_mode_conf(ms, msg);
784 rc = rx_l1_sim_conf(ms, msg);
787 LOGP(DL1C, LOGL_ERROR, "Unknown MSG: %u\n", l1h->msg_type);