Commit Graph

946 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 65774d447d mobile: Use bool to show started can only be true or false
The state handling is complicated and maybe it gets better by
moving started to bool and then the rest to an enum.

Change-Id: I6aef22e7bf954a8a4ecda980c2c558eb8c9180b7
2017-11-27 09:49:03 +00:00
Holger Hans Peter Freyther 42888ed947 mobile: Switch from printf to LOGP statements
Add a mobile application logging category and replace printf with
a LOGP. The code is sadly still using exit in the middle of handling.

Change-Id: I71e7f6e6375a485b45bad76ada2be17b0901577d
2017-11-27 09:48:39 +00:00
Vadim Yanitskiy 7b64e7dbe9 mobile/vty_interface.c: fix Kc / Ki confusion
Change-Id: Ibbd1d080896b5cadc3d4281fe8f839a103a35088
2017-11-24 20:23:57 +07:00
Vadim Yanitskiy cd9b850ee4 host/trxcon/scheduler: process frames in advance
In order to get the transceiver more time to process bursts,
the L1 scheduler should process the frames and send the bursts
in advance (a few frames before), like OsmoBTS does. By default,
the advance value is 20 frames, but this can be adjusted using a
new command line option of trxcon '-f'.

Change-Id: Ic258a169f3554f931d6277e18ca060d029b77f32
2017-11-23 20:05:16 +07:00
Vadim Yanitskiy e8cf6c4eef host/trxcon: fix: use valid names for FSM instances
Since 8c4f5457 in libosmocore there are some limitations on FSM
and FSM instance names. This change adjusts the names of both
l1ctl_fsm and trx_fsm instances.

Change-Id: Icaaac3f51bdcfe4f7723060179b8730c3a06529b
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ac764e78fd host/trxcon/scheduler: separate logging of data messages
Change-Id: I3a33687a688db2a183b546425f71c7a0a7030594
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 5e9959cf6a host/trxcon/trx_if.c: separate logging of data messages
Change-Id: I74ebe0441aeb41c324eafb6b586b2edd9ef4fd1a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 3641fe6123 host/trxcon: use LOGP instead of fprintf
There is no (performance) reason to use fprintf instead of LOGP.
Second one provides more useful information, such as a file name
and a line number.

Change-Id: I86dda5b3d746c7802442e4226578a06c04941721
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f979d44a72 host/trxcon/trx_if.c: fix wrong logging category
Change-Id: I0df0205e160fd9ea5811852077db7c49cddc7e8a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy e38b500794 host/trxcon/scheduler: fix prim queue flushing function
For some reasons, the function, which is used to flush a queue of
transmit primitives, was intended to flush a list of msgb instances
instead of trx_ts_prim, so memory was being cleaned incorrectly.
Moreover, the items weren't actually removed from queue.

Change-Id: Ia84b57350a5c2eee0afebc65f62e30eaddb141d4
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 863ccb7bd2 host/trxcon/scheduler: share common declarations of lchan handlers
The training sequences, data / traffic indication and confirmation
helpers are used by several lchan handlers, like xCCC and TCH. It
would be better to have them all declared within a shared header.

Change-Id: I71980f09a0c0e023370e1a651afc24fff2491552
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy fd9aaaf3d0 host/trxcon/l1ctl.c: handle L1CTL_TCH_MODE_REQ
Change-Id: Ib2332e1610fa873755cdfa745153c7b7d4a72a62
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 28088c8910 host/trxcon/l1ctl.c: include DL frame info in L1CTL_DATA_CONF
The l1ctl_info_dl header is expected to be a part of a
L1CTL_DATA_CONF message, but was missing previously.

Change-Id: Ia8dfaed924fd84395ba9ae539164eaa94f52d30b
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 3b1a03c310 host/trxcon/l1ctl.c: use primitive management API for RACH
Change-Id: I956ddfc4d1b47575715375c08f46c55953ec5fb6
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 7d95f8821e host/trxcon/l1ctl.c: share primitive management code
This change introduces shared primitive management functions,
exposed from the l1ctl_rx_data_req() implementation:

  - sched_trx_init_prim() - allocates memory for a new primitive
    and its payload. Initializes primitive's header, setting
    the logical channel type and the payload length. After
    initialization, the talloc context of a primitive is
    a trx instance, which passed as the first argument.

  - sched_trx_push_prim() - decodes the timeslot index from
    chan_nr and pushes a primitive to its transimt queue.
    The talloc context of primitive is changed to the
    parent trx_ts instance after queuing.

Both functions will be used for handling both L1CTL_TRAFFIC_REQ
and L1CTL_RACH_REQ.

Change-Id: I8169a1ef4ef54d91b50f3e213e4842f54af8b499
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 82b8c21b21 host/trxcon/l1ctl.c: don't fill l1ctl_info_ul into a primitive
The UL frame header isn't used by lchan handlers.

Change-Id: Ia1c63b6f17c3802b29f54299da1151a39edf3a03
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 8e13093c88 host/trxcon/l1ctl.c: retune TRX only if current ARFCN differs
Change-Id: I797dc284bd92d07ad4859f851a44d048407db86d
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 14d0f67064 host/trxcon/scheduler: send stored tx_power to transceiver
Previously a fixed fake value (10) was used.

Change-Id: I8ba70bbda6c8c9249f8eb4294aeb41ab8769a19a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 17a773c734 host/trxcon/l1ctl.c: fix wrong log level
Change-Id: I0ac65d94b0ae3dd370675318a26a65d11c49cbbe
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f5bbe5ebfe host/trxcon: separate logging of L1 Control and L1 Data
L1 Data is quite verbose, while Control is typically limited.
And if you would need to debug some Control message handling,
the Data messages wont overflow your terminal anymore. This
change introduces a new logging category named 'DL1D'.

Change-Id: Id830c8bf913f7a8ddc87c47f70a337ee4623abd8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2e062039b6 host/trxcon/l1ctl.c: do nothing if CCCH mode matches
When the L1CTL_CCCH_MODE_REQ is received, we don't need to
reconfigure anything if the current mode matches requested.

Change-Id: Ib8a511e4edd7210b1806f47e83f316be00a8cbb1
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f9ab2a0b49 host/trxcon/scheduler: clean up some includes
Change-Id: I47e3b953b80f4f822d563579d15498181009ca80
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 0dc5b233e6 host/trxcon/scheduler: share common code for lchan handlers
The training sequences array is currently used by xCCH handlers,
but will be also used for handling both TCH/F and TCH/H bursts.
Moreover the code that forwards decoded L2 payloads to L1CTL
protocol handlers was separated into a new shared function.

Change-Id: I34c3de351362ebd9a070f49bb78d7bd976784b04
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f2179e6763 host/trxcon/l1ctl.c: make l1ctl_tx_data_ind flexible
Now this function can send both DATA and TRAFFIC indications.

Change-Id: I945c10c317155917b6e6ce9d663d9cb46f2e085c
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy c0100cd145 host/trxcon/scheduler: get rid of useless nbits argument
Change-Id: I8508676e2cb347396c6ca6b394f13113f3e63084
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 8fd143ee5a host/trxcon/scheduler: pass trx_lchan_state to lchan handlers
It's better to pass a trx_lchan_state instance directly from
caller to lchan handler instead of passing trx_lchan_type. This
way a handler wouldn't need to find lchan itself.

Change-Id: I47a40542b03ab31da12b0abb1c263c83662ff018
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 58c7faf5eb host/trxcon/scheduler: fix chan_nr parsing
Previously, the chan_nr, received from L2, was parsed in a wrong
way, so in some cases only one logical channel was activated or
some messages (such as Measurement Requests) were sent on
incorrect channel (e.g. on SDCCH instead of SACCH).

This change reimplements the sched_trx_chan_nr2lchan_type(), and
introduces a new function sched_trx_set_lchans(), whics will
parse chan_nr and (de)activate required channels.

Change-Id: I480311c65ef93bbc1644ec708dd2a68fd33091e0
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 18bc7d5e06 host/trxcon/scheduler: ignore incomplete sets of bursts
To be able to decode one xCCH message, it's required to have
all set of bursts collected (4/4). Otherwise we should not
even try to decode an incomplete set.

Change-Id: Iaa63462efe19b8e96102fc8c8d8c968a2df2c70e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 5629699996 host/trxcon/scheduler: drop a meaningless FIXME label
Change-Id: If5497f4fdce22e986f46725cc1575a1e809ccdab
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b4dd3ac9bb host/trxcon/scheduler: use 'tn' instead of 'ts_num'
The new timeslot index designation is more generic for
Osmocom projects, so let's use one.

Change-Id: I8c0118aad439816148490e57938d7e32b6e20877
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 075c1ad738 host/trxcon/scheduler: git rid of sched_trx_find_ts()
After simplification of timeslot management API this
function does not make sense.

Change-Id: I2fc0c68d784c8f01e1452bc46f8e1eaac2917656
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 6aa6690277 host/trxcon/scheduler: fix possible NULL deference
We should make sure that required timeslot is not only allocated,
but also configured, i.e. has a correct multiframe layout.

Change-Id: I1d0b870c389802b51c709d089b80ac3fb3565fa8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy c045bc4fbe host/trxcon/scheduler: simplify timeslot management
As we know the count of timeslots per GSM TDMA frame, it would
be better to have an array of pointers to trx_ts instances instead
of linux list, which is more usable for lists with unknown length.

Change-Id: I9510a5cddde22950ceb8422e0990d59f05ed4d60
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 026ed14c4b host/trxcon: adjust default verbosity level
Change-Id: I91258091b59e5cdd30b767364fb48c3d67980eb7
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2001221d75 host/trxcon/scheduler: optionally reset clock counter
Change-Id: I4565620fc0c5f64133c2674d2c972fc34245cf32
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 00bb1d5a79 host/trxcon/scheduler: implement sched_clck_reset()
It's better to have the clock management API inside a single file.

Change-Id: I92772f3db404e70fdffd530779613196afec61c9
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy e6acd7bd07 host/trxcon: get rid of useless TRX_EVENT_RESET_IND
Change-Id: I2aa4c000b37f64c351a806711b2d19bf27ef82bd
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 806e528bd1 host/trxcon: don't flush trx control messages on reset
Change-Id: I0851f168adeb012a933c796c4180ef507b1c57ec
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b30031356c host/trxcon: get rid of useless trxcon fsm events
Both SCH_EVENT_CLCK_IND and SCH_EVENT_CLCK_LOSS were not handled,
moreover there is no purpose to keep them.

Change-Id: I8efac459a40f4287e3325890809991d5ef46e9b1
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 10fd43e586 host/trxcon/l1ctl.c: reset FBSB expire timer on shutdown
Change-Id: If3c8a34f0c1105c6acbfe4f9233482a31f6558de
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 6c3ce20d75 host/trxcon/l1ctl.c: handle L1CTL_PARAM_REQ
Change-Id: I5c23520dc0f19147b41ad2e13681bf0a62e9facd
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 17481e2b88 host/trxcon/trx_if.c: get rid of CLCK interface
Local clock counter can be corrected using frame number values,
obtained from burst header on DATA interface.

Change-Id: I5a813e3dc1b960831343b8ecb80718291f20e80d
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 9760a84a6d host/trxcon: split sched_lchan_handlers.c
It would be better to have xCCH, SCH and RACH burst handlers
in separate files, because as much code we add to a single
file, as harder it becomes to read and understand one.

Change-Id: I456a60e68b32b792e63dd03ae97159dc101fd4bf
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f604869944 host/trxcon: share trxcon fsm and talloc ctx via trxcon.h
Change-Id: I9ef558f84a6dc1c9b8fc394c48e108676fa169f8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 77b6833146 host/trxcon/scheduler: add a reference to GSM 05.02
Change-Id: I067af9c114bcbc5bd74515d5008e21a07fd0167e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f2af7d2953 host/trxcon/scheduler: confirm xCCH data sending
Change-Id: I40994e7046c25306a0a323910a65e195d2d8fbd0
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f21f7036e8 host/trxcon/scheduler: implement TSC selection
Change-Id: I004cc71aafe0a26e5141a4b2ffa90063e961be31
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b5e4f26f6f host/trxcon/l1ctl.c: handle L1CTL_DATA_REQ
Change-Id: Ia72fd3d55c86697ff144446bbae94f76839eb5a1
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 74f8595156 host/trxcon/scheduler: implement xCCH TX capability
Change-Id: I4da4816dcecc55eb9b4d2d6c631967026a5e4f68
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 824bfa299d host/trxcon/l1ctl.c: handle L1CTL_DM_{EST,REL}_REQ
Change-Id: Ifdf229a6dd3c73ede313d2bfe384032e3887cc3a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 283fb5879c host/trxcon/scheduler: fix TS index in sched_trx_configure_ts()
TS index was not assigned after allocation of a new one.

Change-Id: I1b62218f863acf27fb1d1f46b273b345b97d33d8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ae62021dc9 host/trxcon/l1ctl.c: implement FBSB expire timer
Change-Id: I27f96cbe951de164fcecaf19f8305db5e5b20229
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ff72b0724d host/trxcon/l1ctl.c: fix L1CTL_RACH_{REQ,CONF} handling
Previously, L1CTL_RACH_REQ / L1CTL_RACH_CONF messages were
handled without l1ctl_info_ul / l1ctl_info_dl header, what
caused incorrect data parsing.

Change-Id: I145d137f2cc7de234965e4fe64d9367ed6ccb999
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 4de3591a30 host/trxcon/l1ctl.c: fix incomplete msg in l1ctl_tx_fbsb_conf()
Previously, all L1CTL_FBSB_CONF messages were sent without
required l1ctl_info_dl header, what caused unpredictable
behavior on higher layers (L2 & L3). Let's fix it.

Change-Id: I8dae597bb4c09df36f80944434ce3624569f2cf8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 656e31f762 host/trxcon/scheduler: notify transceiver about TS state
Change-Id: I5783066e7c1b01e4ebb28d10b03f3290ff8a0f37
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 924107d0d8 host/trxcon/l1ctl.c: handle L1CTL_PM_REQ correctly
Change-Id: Ib5a2198f21e747b6169ef141817ef22b241ef9fa
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 794deea3ec host/trxcon/trx_if.c: add power measurement command
Change-Id: Ib947b60248cafad4edeb7e49c2bd3a1f81696239
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ca5eee6e3f host/trxcon/trx_if.c: simplify response matching
Previously, we had both length and string matching of request and
response. To be able to implement commands with additional params
in the future, this change drops the length matching part.

Change-Id: Id4c50115f5f1b1da450ff8b8dcfd6ccf572d23f5
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy d28f65917f host/trxcon/scheduler: confirm successful RACH requests
Change-Id: I079ecebbeeb3843288118fbb55fa520af22859bb
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b91cdc6a4a host/trxcon/l1ctl.c: handle L1CTL_RACH_REQ
Change-Id: I4c06bcf987120c6271b6e2ad94454fa69689a03e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 46b47f5a5f host/trxcon/scheduler: implement RACH handler
Change-Id: I496dd682549570e37e63e7edcfc83a064c13a57f
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2abc7a4998 host/trxcon/scheduler: implement TX queue handling
Change-Id: I2b7bae53901156524134c4904ea1179268d85601
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 59c98b14ac host/trxcon/scheduler: store BSIC in trx_instance
We need to know BSIC value, before sending RACH requests.
So, let's store it in trx_instance and update as soon as
the first SCH burst is received after L1CTL_FBSB_REQ.

Change-Id: I49574c3661f79f3b4941db6c651baebab2665c1b
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 85b700421f host/trxcon/scheduler: modify trx_lchan_tx_func definition
Initially, it was assumed that TX lchan handler will only
compose a burst and return a pointer to the buffer. A burst
itself could be sent somewhere outside, e.g. by caller.

It would be better to send bursts exactly from handler, because
in this case it isn't required to have an external buffer.

Change-Id: Ic9dcdd366e68cec38c5840ed8f8cdda8236d67c7
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 417183b78e host/trxcon/trx_if.c: expose the trx_if_tx_burst()
Change-Id: Iebd644879e2e9067a94cb638b4ec5b75f806923f
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f437a3bebd host/trxcon/trx_if.c: use proper names for burst handlers
Change-Id: I3d36e6d80fcf6353379aa308415c306e1a256a7d
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 0f227d802b host/trxcon/trx_if.c: fix compatibility with OsmoTRX
For some reasons, OsmoTRX sends 158-byte long sequences on DATA
interface, where the latest two bytes aren't used.

Change-Id: Ie9295e9b0d8956d9e87e2ced8cca9d5e68040f88
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 92aca364f7 host/trxcon: reset scheduler when L1CTL is lost
Change-Id: I1fd8a610085c8591a820e784b7122de7b3032d15
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ca1d021c83 host/trxcon/scheduler: drop resolved FIXME label
Change-Id: I5e6b30300a457422b2deb10ff4c051c86beb7cd2
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 3afd469a9a host/trxcon/l1ctl.c: implement L1CTL_CCCH_MODE_{REQ/CONF}
Change-Id: I72f36a99aebcbafd657ceb475fd1c50cc79e2094
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy cc4282f5be host/trxcon/l1ctl.c: implement L1CTL_FBSB_CONF
Change-Id: I33e4702d590a8d67285410fc8f1241bb9d4c50fc
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 99f8aea905 host/trxcon/scheduler: fix channel deactivation
Change-Id: I7c99b7bd99619084727af290b388f7492ba58531
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 7ce986c638 host/trxcon: send L1CTL_DATA_IND directly from lchan handler
Change-Id: Idfc86a59469c7a0bba1c16177502844e59ed8887
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy e738f7827e host/trxcon: handle L1CTL_RESET_REQ inside l1ctl.c
Change-Id: Ie5930dec800885784fb38ce6188c9c969cd2ad4e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy c457cbf712 host/trxcon: handle L1CTL_FBSB_REQ inside l1ctl.c
Change-Id: I5bcf39a20f1c6d3a2472e5e95725c6bb1c77bf5d
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 705fedceeb host/trxcon: bind L1CTL link with TRX and vice versa
Change-Id: I575f8699bf06fd5e86f7935c6ab3216db5a26ec5
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 6ab67cc587 host/trxcon/scheduler: implement SCH decoding
Change-Id: Ic5e7416271d647752cd1aaf90de51fa48286798e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 228d42bc30 host/trxcon/scheduler: implement xCCH decoding
Change-Id: Ieb71e3727b525e85d161855973f63042366ccb05
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy cf5c10f92a host/trxcon: link trxcon against libosmocoding
Change-Id: I9bb45428e6617bd6936d24340e688aef4aeafc8f
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 604ac30825 host/trxcon: handle ccch_mode from L1CTL_FBSB_REQ
Previously, the content of L1CTL_FBSB_REQ message was only used
to obtain a new ARFCN and retune transceiver. Now, since we have
working TDMA scheduler, some other params (like ccch_mode) may be
used too.

Change-Id: Iccabba376d67e091b55a604a2ae87f2aa86362e5
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 62328cb088 host/trxcon: store arfcn and band in trx_instance
Change-Id: I95414ff1033d77f11e231178b7721b70bc45e6df
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ec3a1ba2e5 host/trxcon/scheduler: handle bursts from TRX interface
Change-Id: Iff15daf897f30cb98d4ec4c88b9fc259cb44ea4e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 8baa369b23 host/trxcon/scheduler: implement management functions
This change introduces some new functions to configure
TDMA scheduler. They can be grouped as follows:

  - Scheduler management functions
    - sched_trx_init()
    - sched_trx_reset()
    - sched_trx_shutdown()

  - Timeslot management functions
    - sched_trx_add_ts()
    - sched_trx_find_ts()
    - sched_trx_del_ts()
    - sched_trx_reset_ts()
    - sched_trx_configure_ts()

  - Logical channel management functions
    - sched_trx_activate_lchan()
    - sched_trx_deactivate_lchan()
    - sched_trx_find_lchan()

Change-Id: I6d0f437a68f0eb4e22bf635bf899b08673571085
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2e18fe4631 host/trxcon/scheduler: add basic GSM PHY definitions
Change-Id: I9f4faa15d5ca61af3e3fdbb95952ab4e4e0b7a4b
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 789040f914 host/trxcon/trx_if.c: handle clock indications
Change-Id: I333c1c44578eb62c52d2d059b798dd5feae3e444
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 9b1d398685 host/trxcon/scheduler: add basic clock counter
The core of scheduler is a simple clock counter, which relays
on system time for now. One was a bit simplified and migrated
from OsmoBTS.

Due to system time is not an ideal clock source, the counter
should be periodically corrected by clock indications from BTS.

Change-Id: I27d85bd3e2c8bca3f876f73517027b9fe43c9825
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 90a0d3c78d host/trxcon: initial release of L1CTL handlers
Now it's possible to handle the following requests
from layer23 apps:

- L1CTL_FBSB_REQ
- L1CTL_PM_REQ
- L1CTL_RESET_REQ
- L1CTL_ECHO_REQ

It should be noted, that the L1CTL_PM_REQ isn't
handled correctly yet, due to required task isn't
implemented on the TRX side yet. Instead of this,
temporary we are sending some fake responses.

Change-Id: I343eca3e20922ddd83e06231811200b26da442f3
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 423aeefc40 host/trxcon: integrate osmo-fsm framework
This change introduces the following state machines:

  - trxcon_app_fsm - main application state machine.

    This state machine handles different events, raised
    from program modules (such as trx_if.c or l1ctl.c).

  - l1ctl_link_fsm - L1CTL server state machine.

  - trx_interface_fsm - TRX interface state machine.

The program modules (such as trx_if.c or l1ctl.c) should be as
much independent from each other as possible. In other words,
one module should not call methods from another, e.g. L1CTL
handlers are not able to send any command to transceiver directly.

Instead of that, they should use shared event set to notify the
main state machine about something. Depending on current state
and received event, main state machine 'decides' what to do. This
approach would allow to easily reuse the source code almost 'as is'
anywhere outside the project.

Change-Id: I7ee6fc891abe5f775f5b7ebbf093181a97950dea
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 83a9c9ef50 host/trxcon/trx_if.c: add ECHO command
This command should be used to check transceiver availability.

Change-Id: I6af2d5e413ff7ab751cb34e1659742b0f59b6cca
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 65664d088d host/trxcon: fix NULL-pointer deference
Change-Id: Idc036d4ea32b4aa3f4841d39144ef1733414728e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 48f2cb4b3b host/trxcon: initial release of transceiver interface
This is the second side of the 'OsmocomBB <-> SDR' bridge.
Most of source code taken from the OsmoBTS project.

Change-Id: I96fa3ada05d010f31af419a4950fd8ae2b62ef34
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 9f5fefe792 host/trxcon: initial release of L1CTL interface
There are two sides of the 'OsmocomBB <-> SDR' bridge. One of
them is the L1CTL interface, which is used by existing layer23
applications to drive GSM L1. Exactly this interface is provided
by the osmocon application, but instead of forwarding messages
between both host software and firmware we need to handle incoming
messages from layer23 applications, perform some GSM L1 specific
conversations (coding, mapping, interleaving, etc.), then finally
forward them to transceiver through the scheduler. And vice versa.

This code is just a basic implementation of UNIX socket handlers,
so currently we can only accept and drop connections from layer23
applications.

Change-Id: I58d069bcc7742b42c0bf95e52063933bf2c352ff
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 8975b437ed host/trxcon: introduce a new 'trxcon' application
This app is similar to the osmocon, but designed to
connect L2 & L3 apps with SDR transceiver insted of
obsolete Calypso based hardware.

Change-Id: Ie3c17f19aad9c26f3c49966a7c96b65911f62369
2017-11-19 17:35:07 +07:00
Neels Hofmeyr 0fcd1c147b layer23 vty: fix prompts: insert space after '#'
"All" our VTY prompts have a space after the prompt.
Also do that for '(ms)', '(test-sim)' and '(support)' prompts.

Change

  OsmocomBB(ms)#exit

to

  OsmocomBB(ms)# exit

Change-Id: Id437279e0fa9845630a306958b404efa3b94b492
2017-11-14 09:59:34 +01:00
Holger Hans Peter Freyther 0fd13fcd3c mobile: Make VTY logging commands available to the mobile app
So far logging_vty_add_cmds wasn't called. The main.c might be
shared with other apps so place it into the routine that is
setting up the VTY.

Change-Id: I3db9cf288bce12f51e36caad44e9bc34094638f4
2017-11-09 03:47:20 +00:00
Vadim Yanitskiy 3483d4d844 mobile/gsm322.c: prevent buffer over-/under-run
Change-Id: Ic12587a6c6456b8663e5357cf68a22c6d1927a07
2017-11-09 03:46:41 +00:00
Vadim Yanitskiy 43ecde0fce mobile/gsm322.c: prevent calling memset() with zero length
This change prevents a possibility of calling memset()
with constant zero length parameter, and the corresponding
compiler warning.

Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
2017-11-09 03:46:41 +00:00
Holger Hans Peter Freyther 52fbe66ca7 mobile: Do not exclude DGPS from the list of default categories
I don't remember why we parse the categories like this. First if
the mobile doesn't use a subsystem there is no harm to have it
enabled, second the default levels can be adjusted for all apps
and third we have the VTY to reconfigure these logging targets.

Change-Id: Ia874b7ed127026b8395072a3bac2aed9944b1cce
2017-11-09 03:45:24 +00:00
Neels Hofmeyr 87038afe86 vty: skip installing cmds now always installed by default
vty_install_default() and install_default() will soon be deprecated.

Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I300a4b34a2031fd09d110ef18375d140a6dca7ba
2017-11-09 01:14:49 +00:00
Vadim Yanitskiy d0ed4de085 host/mobile: use osmocom_ms as talloc context
As we use talloc, it's absurdly not to use the main feature of
the library - hierarchical memory management. This change sets
talloc context of all sub-allocated objects to related osmocom_ms
instance. So, as soon as osmocom_ms instance is destroyed, all
sub-allocated chunks are getting destroyed too.

Change-Id: I6e3467ff739f3e6dc8dd60cc6d1fcd3f8e490ce9
2017-11-08 18:46:57 +07:00
Vadim Yanitskiy 8dbacacd37 mobile: get rid of unused variables / functions
Change-Id: Id867ffed9b2b67025320d002e1e009e19c759a23
2017-11-05 23:41:42 +07:00
Vadim Yanitskiy 4fbf93040e mobile/gsm411_sms.c: use secure gsm_7bit_(en|de)code_n
Since some 'gsm_7bit_*' functions were deprecated and replaced by
more secure ones with the '_n_' postfix in names, it's better to
use the updated functions.

Change-Id: I58150e9b74699e5f54b9a83416ad8efcb2eccd8e
2017-11-05 23:41:42 +07:00
Vadim Yanitskiy b353686451 mobile/gsm48_mm.c: use secure gsm_7bit_decode_n
Since some 'gsm_7bit_*' functions were deprecated and replaced by
more secure ones with the '_n_' postfix in names, it's better to
use the updated functions.

Change-Id: I4499b592a0dfea71462aed19fe641419d79b3cbd
2017-11-05 23:41:42 +07:00
Vadim Yanitskiy 37872f1032 mobile/gsm480_ss.c: use secure gsm_7bit_(en|de)code_n_ussd
Since some 'gsm_7bit_*' functions were deprecated and replaced by
more secure ones with the '_n_' suffix in names, it's better to
use the updated functions.

Change-Id: If8a1983592f5800e3981f29962eb333ac9473f40
2017-11-05 23:41:42 +07:00
Vadim Yanitskiy 584cc7a26b mobile/vty_interface.c: fix incompatible pointer type warning
According to the vty_app_info struct definition, the go_parent_cb()
should return an integer, but not enum. So, this change fixes the
following compiler warning:

> warning: initialization from incompatible pointer type
>   .go_parent_cb = ms_vty_go_parent,

Change-Id: Ib55e43eaaebdd9fe0d74a030b1057ae82804a77e
2017-11-05 23:41:42 +07:00
Vadim Yanitskiy b7ff8b5893 mobile/main.c: fix deprecated call to msgb_set_talloc_ctx()
The usage of msgb_set_talloc_ctx() was deprecated many days ago,
so it's time to use the proper replacement.

Change-Id: I56440d8e2152c4bb2e5ad677f88c61742d2ad9ca
2017-11-02 14:21:16 +00:00
Vadim Yanitskiy aceb6a80d8 mobile/vty_interface.c: add missing 'vty/misc.h' header
This header contains declaration of the osmo_talloc_vty_add_cmds().

Change-Id: Icdafb22758897cfb67e249f37991f4af4213a5fa
2017-11-02 14:21:16 +00:00
Vadim Yanitskiy 8a617cd160 mobile: register the talloc context introspection command
This change registers the command, which is now implemented in
libosmocore since the 463deef8c209dd7eb023ac70bf41fa9893ad35ed
and allows to introspect mobile application's talloc context
directly from the VTY interface.

Change-Id: I979d64ae63d385f4fd082a4e3f981cbf5ab28338
2017-10-29 17:46:10 +00:00
Vadim Yanitskiy 363d4d22da mobile: clean up and share example configs
It is better to have a shared example config files directory,
like other Osmocom projects do.

Change-Id: I903f31a8afc518ac258cdaeaf76430de07f7edea
2017-10-23 15:11:16 +03:30
Vadim Yanitskiy da9e830af0 mobile/vty_interface.c: do not write 'exit' to config
Since we use indenting as means to implicitly exit child nodes,
no need to write 'exit' at the end of each child node.

Change-Id: I73b0f3926d766d21ca68c8e01b7fc70b2b4636c9
2017-10-23 00:33:58 +03:30
Vadim Yanitskiy c5a08ef4f4 mobile/vty_interface.c: do not install default commands
Since in recent version of libosmocore default commands (such as
'exit' and 'end') are being installed by default, no need to
install them twice. This will crash the program.

Change-Id: I82c8d04ccc7dc3f19589a79b859a2c993bd1d39c
2017-10-23 00:33:29 +03:30
Vadim Yanitskiy ae31c37d2b mobile/main.c: clean up config file selection logic
The 903e2515 introduced the following problems:

  - The home variable is allocated dynamically by talloc,
    but not being freed. There is no need for dynamical
    memory allocation, as the getenv() returns a pointer
    to a value in the environment or NULL.

  - In case of custom configuration file, a pointer to
    a part of stack (not heap) is passed to talloc_free().
    This may cause unexpected behaviour of segfault.

Let's fix both of them.

Change-Id: I79cc3b954c3018b7e780f6351c3030c3062470b5
2017-09-09 00:40:43 +03:00
Max 903e2515f5 Add arbitrary config file location support
All other Osmocom projects use '-c' command line option to specify the
location of config file. Let's do the same with fallback to existing
implicit config file name logic.

Also print config file path and vty host on startup.

Change-Id: Idaac3ff8d1f8541e00c45290db948a67bb899311
2017-09-07 18:08:03 +02:00
Harald Welte b2c19fc5d3 VIRT-PHY: Add support for GPRS / TBF mode
we add a new STATE_TBF to vthe MS model and add some L1CTL primitives
to configure that TBF mode as well as to enqueue transmissions for
blocks at a given USF+TS.

Change-Id: Ie6f37090bd45f463aa25d9e00bc06f563be5264a
2017-08-20 22:19:17 +02:00
Harald Welte 35564c691f VIRT-PHY: virt_l1_sched: Pass timeslot number into call-back
When we schedule a given frame for transmission, we save its timeslot
number.  However, the callback doesn't get informed about this so far.

Change-Id: I608a91ae8e2a57a2d6f87f4b873c82edb0215bf6
2017-08-20 22:19:17 +02:00
Harald Welte ae15e7f9de VIRT-PHY: Support forwarding of CBCH similar to BCCH/CCCH
Change-Id: I3e6f936603e43e885b28953be5ac262e3fb7c09a
2017-08-20 22:19:17 +02:00
Harald Welte 3595402641 virtphy: Add SIGINT+SIGTERM handlers
Change-Id: I2fe65e0c1912c4d72c276a2db169f0bdbcbda2b8
2017-08-20 22:19:17 +02:00
Vadim Yanitskiy a52abd5d4f vty_interface.c: use RPLMN from settings if preset
Previously, when testcard was attached via VTY interface, the
initial values were used for MCC / MNC, LAC and TMSI, even if
correct RPLMN settings were set.

Change-Id: Ic70889cdb6be95f06d0c2df710524b4128b5f72b
2017-07-27 12:25:34 +06:00
Harald Welte 5e0fa863cb VIRT-PHY: enable proper memory leak debugging
We make sure that all allocations are tracked back to one talloc root
context, and install the usual SIGUSR1 handler to dump the talloc
report.  This enables us to do interactive debugging for memory leaks
while virtphy is running.

Change-Id: I73b3cf86eea5f56595c1b045cf0fde8035ff185a
2017-07-19 14:10:04 +02:00
Harald Welte dd3fd10903 VIRT-PHY: We don't do line-breaks inside log statements
Change-Id: I27cba13ee782c53a9b2406319241fc7f4e3db0bd
2017-07-19 14:00:09 +02:00
Harald Welte f122d4cd36 VIRT-PHY: Properly destroy l1_model_ms after disconnect
If a MS disconnects, we need to clean up all related state

Change-Id: Ib7adef61150b5a4338483019e4dd75d7279d1f5d
2017-07-19 13:53:30 +02:00
Harald Welte c0fba7a298 VIRT-PHY: Change default log levels
This will basically only print L1C message for all L1CTL happening
between MS and the BTS, while suppressing the GSMTAP/virtUM and L1P
related messages.

Change-Id: I9513db3cee12644ed9b9858e13b740ffd27aba24
2017-07-19 13:39:54 +02:00
Harald Welte d80c6f4ef8 VIRT-PHY: Clean up logging statements
The generated log lines have been *super* long, let's make them
significantly shorter.  Also, differentiate between DEBUG and INFO
level, so normal operation with LOGL_INFO will not spam the user while
still printing useful information.

Change-Id: If06a8b5f99349796d66a71201524361a6547945a
2017-07-19 13:01:56 +02:00
Harald Welte f7dafcc5d2 VIRT-PHY: Separate logging of L1 Control and L1 Data
L1 Data is quite verbose, while control is typically limited, so let's
make sure we log them as separate sub-systems

Change-Id: Idebc371a63508c593855486ff01b2ba6e8c2cfd1
2017-07-19 12:14:35 +02:00
Harald Welte 198dbda3c8 VIRT-PHY: Log MS context number whenever possible
Now that we can have multiple MS connected to one virtphy instance,
it is important to log some context whenever possible.  To do so, we
introduce a monotonically increasing MS number which gets assigned
whenever we allocate a l1_model_ms and printed when the LOGPMS() or
DEBUGPMS() macros are used.

Change-Id: Id7d9507126a03def5bd7690f1dbe987f9a749e65
2017-07-19 11:53:13 +02:00
Harald Welte f5e0f6424b VIRT-PHY: Major rewrite to deal with muliple L1CTL clients
Change-Id: Ibfb2a93f8b45a95215c01368b1a52d92283474e6
2017-07-19 11:30:26 +02:00
Harald Welte ef9ee6116b VIRT-PHY: Don't redefine GSMTAP port number, use libosmocore
Change-Id: I11d04d76292c52ec5ab70893e8c6a2e55586b2ec
2017-07-19 00:32:36 +02:00
Harald Welte 7b6071208e VIRT-PHY Use libosmocore unix domain socket helper
Change-Id: Ic0fa003bd7c7468d39a0c39fbea89000d576a4f3
2017-07-18 23:36:17 +02:00
Harald Welte c2083feefa VIRT-PHY: reorganize data structures
* l1_model_ms can become a static member of l1_model_ms
* crypto_info_ms can become a static member of l1_state_ms

Change-Id: I94ca4dad1c6c668ce6307d5e5d728b1c1502af12
2017-07-18 22:18:52 +02:00
Harald Welte 3ee8ac1593 VIRT-PHY: some more comments/documentation
Change-Id: I24fc98624178e9441d6cfcd61bc14e17c1391e9e
2017-07-18 21:41:24 +02:00
Harald Welte 70dd7e5b75 VIRT-PHY: Use IPv4 multicast groups for private / local scope
The addresses in the original code make little sense:
* 224.0.0.1 is "All systems on this subnet" and not routed
  outside the local ethernet segment
* 225.0.0.1 is in a RESERVED range that shouldn't be used

Change-Id: I8e3acd745e65a6cfa70b681a440da6a59a1ed0b5
2017-07-13 17:18:00 +02:00
Harald Welte c4324da7c6 VIRT-PHY: Use osmo_fd_close() introduced in libosmocore
libosmocore has recently received a new function osmo_fd_close() which
can be used to replace the private fd_close() function in this code.

This requires Change-Id Icd0933eed6a24edde7cdcb378e138897ecc5332c in
libosmocore.

Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
2017-07-13 16:37:27 +02:00
Harald Welte 4f9913f1fd VIRT-PHY: Use new OSMO_SOCK_F_NO_MCAST_{LOOP,ALL} flags
libosmocore has recently gained support for flags like
OSMO_SOCK_F_NO_MCAST_LOOP and OSMO_SOCK_F_NO_MCAST_ALL that can be
passed to the socket initializer functions, further reducing complexity
of the code in osmo_mcast_sock.c here.

The related change-IDs are I5ab5de45c0b64ceb3636ea98245a23defa24ffd4 and
I24a5b1ebc3f84d2d5d4734e54df50efaea26490b in libosmocore.git.

Change-Id: I961aa07a381fef2cf9a2fb5357937864364ca04b
2017-07-13 16:35:50 +02:00
Harald Welte 48d2a55b40 VIRT-PHY mcast_sock: Use uint16_t for ports, bool and const
Change-Id: I4eab1da8d43fdad05c04f23d89711081c4696fe7
2017-07-13 14:24:57 +02:00
Harald Welte 16da443e73 VIRT-PHY: mcast_sock: properly clean up in error paths (close/unreg socket)
Change-Id: I2c22359735af6b867e25e0f566cadbc88f21ef44
2017-07-13 14:18:09 +02:00
Harald Welte 0d0d2ec724 VIRT-PHY: Further simplify mcast_sock code
By avoiding dynamic allocations and relying on osmo_fd, we can
significantly simplify the code.

Change-Id: Iad653686ac2bda5b3c92c30b4386ee7727d16271
2017-07-13 14:16:31 +02:00
Harald Welte 3017a977f7 VIRT-PHY: mcast_sock: We must close the fd before setting it to -1
Change-Id: Id8e72c8800a8b3021ab350acaebd912f1b387063
2017-07-13 13:59:40 +02:00
Harald Welte 91a0c20bb3 VIRT-PHY: mcast_sock: Don't keep subscribed multicast group around
We can avoid having to keep around the multicast group in a chunk of
dynamically allocated memory and simplify related code.

Change-Id: Ic39ffe73dfd2cb8ffefb9614340e275dac87bd50
2017-07-13 13:58:28 +02:00
Harald Welte dd94566f7b VIRT-PHY: mcast_sock: Avoid dynamic allocation of osmo_fd member
Change-Id: I11e0137849797eb67047b4ddca0e917c599ed909
2017-07-13 13:54:21 +02:00
Harald Welte a2f06f28e2 VIRT-PHY: osmo_mcast_sock: Get rid of server_sock.sock_conf
We don't need to store this data, we cans simply connect the socket to
the destination mcast address instead.

Change-Id: I3c98653c41eff9feb649d9c47cd40b26fd81ed05
2017-07-13 13:49:37 +02:00
Harald Welte 46a4524126 VIRT-PHY: osmo_mcast_sock.c coding style cleanup
Change-Id: Ie45ea5911167600cb9a1a79dfcd9656be1e91dab
2017-07-13 13:48:04 +02:00
Harald Welte 8a2080b96a Port osmo_mcast_sock to libosmocore socket routines
Change-Id: Ia44c086fb8e428edf49bafd1662c31b2dc2bfc43
2017-07-13 13:44:41 +02:00
Harald Welte 271eca57a9 VIRT-PHY: Use gsmtap value_strings in recent libosmocore
In Change-ID Iaf8a99912f42a56ef785a1642e18238c0b67cf68 libosmocore
introduced value_strings fro the GSMTAP_CHANNEL_* and GSMTAP_TYPE_*
constants, so we can remove the private tables.

Change-Id: I771dbe079fc6d1a5e66e958deb832c1168990851
2017-07-13 12:23:05 +02:00
Harald Welte 656cd327f9 VIRT-PHY: common_util: chantype_gsmtap2rsl() now in libosmocore
As of Change-Id Ie1bc00670887064da0fea61c3dab036c23ceea25, this function
is offered by libosmocore.

Change-Id: Ie269afe314967fd2c42b91ee854c217f699252dc
2017-07-13 12:23:00 +02:00
Harald Welte c8d1ad36eb VIRT-PHY: Fix all compiler warnings on gcc-6.3.0
Change-Id: I95b93ec907fbfd180a0f2ac681dd63791ede24db
2017-07-12 23:26:26 +02:00
Harald Welte 5abc25c852 VIRT-PHY: Make sure heaer files are part of 'make dist'
Change-Id: Ib4cd0463da1cf22e04a1debfed55a33f7b6542d4
2017-07-12 23:26:26 +02:00
Harald Welte 7e65a1483f VIRT-PHY: coding style / API usage cleanup
This is the result of my manual clean-up of the many coding style issues
found in the stumpf/virt-phy branch of OsmocomBB.  Some may remain, but
it's much closer to what we're used to in the Osmocom world now.

Change-Id: I3aa95dbef75d7749d490aad0237d074528527e8b
2017-07-12 23:26:26 +02:00
Harald Welte 020186009c VIRT-PHY: Remove non-overridable CFLAGS "-g -O0"
If the user wants debugging / no optimziation, they can always pass the
related CFLAGS at ./configure time, there's no nee to have them
hard-coded in the actual Makefiles.

Change-Id: I6a2b30f946579bbd49bf66c4f59d160a975a1b56
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 203f7e0c7f VIRT-PHY: Configurable signal power reductions for multiple arfcns.
Model was expanded and holds now power management information consisting
of an array of received power levels for all arfcns and one for the
reduction of this signal in dbm. The reduction is configurable by
commandline by --arfcn-sig-lev-red 666,12:888,13. The signal level is
assumed to be max level (-63) if a packet from that arfcn is received
within a timeframe (also configurable via  cmd -- timeout-pm 5:800 ==
<seconds>:<microseconds>). After that timeout it will be reduced to min
level (-110).

Change-Id: I369ca26703f14bba4e9334b8f417deef640462f9
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 59cc3c3ab1 VIRT-PHY: Extracted common virtphy utils.
Change-Id: I759c6e9805ab012f9553bcba9b5d379193462955
2017-07-12 23:26:26 +02:00
Sebastian Stumpf ba1f7c2974 VIRT-PHY: Added option parsing.
Available options:
dl-rx-grp: mcast group messages on downlink are received from
ul-tx-grp: mcast group messages on uplink are sent to
port: port used for mcast sockets
log-mask: logging mask
l1ctl-sock: l1ctl socket path to connect to l23

Change-Id: Id939e5d7b90b592c85ad19f3ad6f459351e2d8f6
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 7ea7b8ac05 VIRT-PHY: Add downlink filter for msg on dedicated channels.
Messages incoming on dedicated channel (SDCCH/8, SDCCH/4) are no longer
forwarded to l23 if their timeslot/subchannel is not fitting the ones
configured by l23 via L1CTL_DM_EST_REQ.

Change-Id: I6112b20e31c25636e53d3a6cda6f7443a94ff9c3
2017-07-12 23:26:26 +02:00
Sebastian Stumpf c1705d53db VIRT-PHY: Fixed power management and PCS sync.
PCS flag was ignored in fbsb. Power management returned a perfect link
for all possible arfcns causing the mobile trying to sync to all these
afterwards. This took too long and PM now only returnes a good link
quality for arfcns configured as available.

Power management was also extracted to an own file.

Change-Id: Ia1b79aa47c9df3b1e316122455ceccb4a66724e0
2017-07-12 23:26:26 +02:00
Sebastian Stumpf e7600a0d57 VIRT-PHY: Fixed FACCH processing on TCH.
As TCH is not supported in GSMTAP yet, all incoming frames on the
virt-phy are forwarded as FACCH to the l23 for now.

Cleanup code in virt_prim_data and virt_prim_traffic.

Change-Id: I6b41f21b6984e62ad98edfe4398bd678d5b2dad5
2017-07-12 23:26:26 +02:00
Sebastian Stumpf a090f635b0 VIRT-PHY: Scheduler - correct handling over hyperframe repeat.
Scheduler will no longer skip tasks that are scheduler for a framenumber
greater than the current fn because of a hyperframe repetition.

Change-Id: I683ba18b5dee308d58f9a95a0ee10e22da207eda
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 30cc674df8 VIRT-PHY: Calculate correct scheduler fn for data- and tch-msgs on ul.
Proper calculation of the scheduled frame number and appending the jobs
with that fn to the scheduler. Thus uplink msgs are scheduled at the
(approx.) correct fn and with this fn set in the gsmtap hdr.

Change-Id: I0f44d0b5b9208755e671c619d1f851a043aefb54
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 241fe9c3e2 VIRT-PHY: Fixed error causing send msgs to be received on same sock.
This could be disabled setting socket option IP_MULTICAST_ALL = 0.

Change-Id: Ia2838c4cd39bfac04c014b4c8512466b301d8875
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 360de6bead VIRT-PHY: Data and traffic req from l23 now use scheduler.
Msgs are not put on virt um directly in the handler like before, but are
scheduled. FN they are scheduled with not yet properly calculated.

Also, code was extracted from lactl_sap.c into own files.

Change-Id: Ibe57abebadf294f1407d82cef3fd0b51e7c1b23e
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 2dfe603117 VIRT-PHY: Using IANA-registered port 4729 for GSMTAP for virt um.
Change-Id: Id8e262c9a9a6260353bfb98e774b9d0b6eecae53
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 63f3ce2482 VIRT-PHY: Uplink scheduler implementation.
Implemented simple scheduler depending on frame number in downlink. It
will be executed each time we receive a msg on downlink and send out all
scheduled uplink msgs with a sched_fn smaller than the one of this
received downlink msg.

Further refactored l1ctl_sap by extracting rach and fbsb logic and
putting it to own files virt_prim_fbsb.c and virt_prim_rach.c

Added simple states to the ms layer 1 model, indicating if the ms is
currently searching for bts, syncing to or camping on a bts. Downlink
will be handled differently dependent of the state.

Change-Id: I8937b1d6568f5d3750bbdc5d77fa283074d5365e
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 0a68f6884c VIRT-PHY: Uplink flag and arfcn check.
Incoming messages with the uplinks flag set in the arfcn or another
arfcn than the cell's we are camping on are ignored.

Change-Id: Ibb78ac68172fceaa04acca81271940632e52d857
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 5385c7d19a VIRT-PHY: Added example config for 2 mobile instances.
Change-Id: Iecfed3933ca88aa7a027e6247a8b71e28ee1883e
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 5490fa9097 VIRT-PHY: Enable multiple phy-instances by configurable l1ctl-sock-path.
Change-Id: Ief22eedacd1929450ff68f553068b95a778df80f
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 2e265c897a VIRT-PHY: Cleanup dirs, makefile, dependencies and formatting code.
Change-Id: Ibd68a03bcc439c262ba513782936c6b62937eaaa
2017-07-12 23:26:26 +02:00
Sebastian Stumpf fa2ce6396f VIRT_PHY: Improved l1ctl-to-l23 interface + gsmtap header parsing.
Fixed mapping from gsmtap msg type to rsl msg type and vice versa.
Proper chan_nr decoding instead of usage of dummy values for timeslot /
link_id / subslot.
Implemented missing l23 rx handler routines.

Change-Id: Ibad741d112643c55091b8ba00164b05d728ae1a1
2017-07-12 23:26:26 +02:00
Sebastian Stumpf 2fe2ba3d46 VIRT-PHY: Implemented RACH on uplink.
RACH will now be transmitted over GSMTAP virtual UM interface if L1CTL
command is received.

Minor further changes:
- Incoming messages are now only then forwarded if ms is synced to a
cell (fbsb cmd from l1ctl received).
- SDCCH/4/8 are forwarded to l23 for now as we don't use
encoding/ciphering (yet) this should not be a problem.

Change-Id: Ic15188c5c0bba96c223d689be733324a9778a2e8
2017-07-12 23:26:26 +02:00
Sebastian Stumpf a4aaa14878 VIRT-PHY: Initial commit of virt-phy to work with osmo-bts virt-phy.
This patch implements a virtual physical layer replacing the air
interface. The purpose is to get rid of the hardware requirements
and be able to start testing and implementing layer 2 communication
functionality on one machine. Multicast sockets are used to enable
bidirectional communication between the BTS and the MS process.
The GSMTAP protocol designed for wireshark capturing is used to
encapsulate the payload on the virtual physical layer.
The virtual physical layer on the osmocom-bb side implements the
L1CTL interface to the layer23 apps like mobile.

* Working mcast socket communication and extraction of its
  functionality.
* Basic handlers for file descriptor callbacks from incoming L1CTL
  messages and extraction of that functionality to a l1ctl socket class.
* Multiplexing to different routines depending on incoming L1CTL
  message type.
* Uses virt_um and osmocom_mcast_sock implementation from osmo-bts
  virt-phy.
* Ecapsulation and parsing methods to and from GSMTAP messages.
* Basic handlers for file descriptor callbacks from incoming mcast
  messages on the virtual um.
* Multiplexing to different channel routines based on GSMTAP header
  channel type.
* Example configuration for l23 app mobile using virtual test sim.

Change-Id: I203c8ec58326e52a09603a37232fce7ae3641415
2017-07-12 23:26:26 +02:00
Vadim Yanitskiy 064ffe6563 host/mobile: use talloc for ms->name allocation
The approach of talloc memory management reduces memory usage,
and prevents some buffer overflows, which were possible before.

Change-Id: Icd6706117fdd7f1b3481b0e3817bbb3b31f12f60
2017-05-25 11:43:49 +00:00
Vadim Yanitskiy 3aaf127cc1 mobile/gsm48_mm.c: strip unused variable
Change-Id: I2708628263bec4bc6bf53a357928e23609b40c64
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy b2a1f72710 mobile/gsm480_ss.c: gsm480_mmss_ind: return rc
Change-Id: Iabaccdbdfc5a5eb6424bd1603f405241650f13d8
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy 81b6e7d9f4 mobile/gsm48_rr.c: fix BA range exceed check
Change-Id: Ic2ebe9faeeda7ce812527962d209e6049f2dfc75
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy e569ac3bc5 mobile/gsm480_ss.c: fix copy-paste error
Change-Id: I23287c0f31bee9c1b710f17f932633d2c621dab0
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy 03485409be mobile/gsm322.c: fix mcc/mnc typo
Change-Id: I4a3aaa0465598b17ccd30ec4cbeb90429216540e
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy 06f44d3772 mobile/gsm322.c: check fwrite() return value
Change-Id: I74ad6e540c98ab4914e7a2ea725dd23f5a2fd034
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy 03aace5818 host/app_mobile.c: do not exit in mobile_new()
Previously, if there was any error during a new osmocom_ms
structure allocation, the mobile_new() used to call exit()
directly. Since we always check return value of this function
it would be more correct to return NULL in any bad case.

Change-Id: I9a594dd1d133f0c0740dc3bff41633f94099b593
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy 0f39694210 sap_interface.c: drop meaningless condition
If sap_state is equal to SAP_NOT_CONNECTED, it cannot
be equal to another value at the same time. So the
second part of condition doesn't make sense.

Change-Id: I3038fc15745dc4be796d894002524e6b2dd5c90e
2017-05-25 02:11:53 +03:00
Vadim Yanitskiy f978a66ca6 osmocon.c: strip unused variable
Change-Id: I295785295c108798e0c235e78bd8fd8f3c585d16
2017-05-24 22:22:33 +00:00
Harald Welte 0cdf4b0a68 Support Early Classmark Sending
If SI3 rest octets indicate early CM Sending is allowed, and the
'support' indicates we support it (which we now do by default), then
send the classmark change message every time a LAPDm link layer is
established.
2017-01-15 20:46:27 +01:00
Harald Welte c9ad46ac75 Fix encoding of padding at end of CLASSMARK 3 IE
Contrary to e.g. SI rest octets, the padding at the end of a CLASSMARK 3
Information Element is padded with zeros, not with L.  There is no 0x2b
padding in this case.
2017-01-15 20:46:26 +01:00
Harald Welte 214236fd5d mobile.c: Don't register 'end' command to CONFIG_NODE
The CONFIG_NODE already has an 'end' command, and recent versions of
libosmocore actualyl check for conflicting/duplicate command
registrations and make the application crash in this case.
2017-01-15 20:46:26 +01:00
Harald Welte f95d518c63 mobile: Finally fix copyright notice
After 7 years it is about time...
2017-01-15 20:46:26 +01:00
Яницкий Ва дим bec943f0b7 host/mobile: Improved SAP interface integration
1) Now the SAP interface is selectable as SIM source using the 'sim sap'
   command in VTY.
2) SAP connection starts only if it is configured as SIM source.
3) Fixed sap_socket_path configuration r/w errors.

Written-by: Яницкий Ва дим <axilirator@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2016-01-18 21:08:45 +01:00
Яницкий Ва дим 65f05ce618 mobile: Fix for "Added runtime selection of gps device"
The 'gps host HOST:PORT' line in the config file now is generated correctly.
So that it is parsed correctly when loading the config on next startup.
Also the gpsd port now is parsed as it should without a colon.

Written-by: Яницкий Ва дим <axilirator@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2016-01-18 21:08:45 +01:00
Harald Welte ef0d8ec31d modernize AM_INit_AUTOMAKE
according to http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
2015-12-31 14:12:40 +01:00
Harald Welte c400827539 autoconf: Migrate from INCLUDES to AM_CPPFLAGS 2015-12-31 14:12:14 +01:00
Sylvain Munaut fc20a37cb3 host/mobile: Finish working support for the SAP interface
Patch mostly written by Nico Golde
and some cleanup/testing by Domonkos Tomcsanyi

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-04-28 15:57:54 +02:00
Igor Almeida e6372a2c24 layer23: initialize l2h/l3h pointers in rx_l1_rach_conf
Signed-off-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-09-06 23:47:15 +02:00
Max d7b69212f8 mobile: Use osmocom auth API instead of direct calls
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-15 19:00:13 +02:00
Andreas Eversberg 2d0a5acaf3 mobile/SS: Fixed bug in parsing of known supplemenary service codes
Use correct variable to check if supplementary service code is known
or not.
2013-12-24 07:33:58 +01:00
Andreas Eversberg 8a8796802b osmocon: Improve performance by handling several serial bytes at a time 2013-06-19 15:16:58 +02:00
Bhaskar f2ab5e1496 host/mobile: Add 'extern' qualifier to config_dir in app_mobile.h
This prevents duplication definition with main.c

From: Bhaskar <niceguy108@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-05-23 08:30:15 +02:00
Bhaskar 761127b6b4 host/mobile: Fixup in error checking path of l23_app_init
From: Bhaskar <niceguy108@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-05-23 08:28:18 +02:00
Bhaskar c6cab89f76 host/osmocon: fix some printf format specifier in handle_write_dnload
From: Bhaskar <niceguy108@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-05-23 08:25:18 +02:00
Sylvain Munaut 2529320420 host/mobile: Fix trans_assign_trans_id() users error checking
The returned value of trans_assign_trans_id() must be stored into a
'int' rather than uint8_t to allow proper testing of negative return
values (errors).

Thanks to Bhaskar <niceguy108@gmail.com> for the original
patches.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-05-23 08:22:48 +02:00
Bhaskar fde82f554b gsm48_mm.h: Added get_mm_name() to header 2013-05-23 07:51:09 +02:00
Bhaskar 2542a55c87 gsm48_mm.c: Bugfix: payload_len should be signed int
As we later check if payload_len < 0, it should be signed, not unsigned.
2013-05-23 07:49:50 +02:00
Bhaskar 78bcbd6cdb osmoload: Fix fall-out from msgb_get() / msgb_pull() transition
Bugfix in Osmoload.c: Assigning correct value to data pointer in
LOADER_MEM_READ. Wrong value was introduced in last update when
msgb_get() was replaced by msgb_pull() which returns end of data instead
of start of data.
2013-05-23 07:44:50 +02:00
Sylvain Munaut 7684cdd20c host/mobile: Remove duplicate A5/1 support indication in vty 'show support'
Patch-by: Martin Hauke <mardnh@gmx.de>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-04-14 09:00:51 +02:00
Sylvain Munaut d27561b00f host/mobile: Fix comment typo
Patch-by: Martin Hauke <mardnh@gmx.de>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-04-14 08:59:47 +02:00
Steve Markgraf 1479b6812b osmocon: embed chainloader
This allows to directly load highram-images on
compal phones with the commandline-switch
-c.

Signed-off-by: Steve Markgraf <steve@steve-m.de>
2013-04-07 11:34:48 +02:00