Commit Graph

1981 Commits

Author SHA1 Message Date
Harald Welte a362ee90b4 add sercomm unit test
Change-Id: I9e2e7fcda28e7c6844d5faa09e02acf537cea44d
2017-05-17 15:15:09 +01:00
Harald Welte 7af6d22a4e sercomm: Include in libosmocore Makefile
Change-Id: If9d50d634381f43b2c67b97fea36a462a66e4559
2017-05-17 15:15:09 +01:00
Harald Welte fe71ee9d99 src/panic.c: Remove unneeded #include of gsm_utils.h
Change-Id: I25cea5d3a4a900550e8f18c2bea392e642bfb191
2017-05-17 15:15:09 +01:00
Harald Welte df8e89f066 sercomm: Rename sercomm_lock() to sercomm_drv_lock()
The user of the code is supposed to provide a "driver" implementing
those calls according to the specific target architecture/hardware.
This only applies to non-host (i.e. embedded) builds

Change-Id: I9a6848f23b70fc32f4de10149d857374f76f000d
2017-05-17 15:15:09 +01:00
Harald Welte 1d640889df sercomm: remove unrequired helper functions
osmo_sercomm_{bind,get}_uart() are not really needed anymore, as
sercomm_inst is public and thus the user can access the uart_id member
directly.

Change-Id: I6d57709c3764036046202f16a26c9eb87426c8d1
2017-05-17 15:15:09 +01:00
Harald Welte 8a4eb837ab sercomm: Move HDLC related defines into C file
Those values are not relevant to the sercomm user, only to the
implementation and thus can remain inside sercomm.c

Change-Id: I5700a45985b7c119c6338932171aae62ee4e2d22
2017-05-17 15:15:09 +01:00
Harald Welte ea3d3ba595 sercomm: Add doxygen-style documentation to public API
Change-Id: I2d8b11905692920d328262836420f01305be489e
2017-05-17 15:15:09 +01:00
Harald Welte 1a97e2c962 sercomm: include header file from osmocom/core
Change-Id: Iff5ff3a51d7781bcfb3aff0839b733bc7a71b7e5
2017-05-17 10:46:40 +00:00
Harald Welte f6adcd7dd6 sercomm: make rx msg size configurable per instance
Change-Id: I835506e26e83232e1e7290c0da04d389c8d7fb40
2017-05-17 10:46:40 +00:00
Harald Welte 1358836282 sercomm: introduce osmo_ naming prefix in struct and function names
Change-Id: If4e22f182a47b72b1fe43146716a4fbccceb62e6
2017-05-17 10:46:40 +00:00
Harald Welte cc95f4b06d sercomm: Enable multiple instances of 'sercomm'
Rather than having one global instance, let's permit multiple instances
of sercomm to co-exist, with all API functions extended by the instance
as first argument.

Change-Id: I0f3b53f464b119d65747bcb0be0af2d631e1cc05
2017-05-17 10:46:39 +00:00
Harald Welte c68af6a64b Import sercomm.c from osmocom-bb
This imports the file src/target/firmware/comm/sercomm.c from
osmocom-bb.git without introducing any modifications.  It will not even
be built yet, as Makefile integration is intentionally left until it has
been adapted to work inside libosmocore.

Change-Id: I9ee199381c7b5986a9540d124836cdddd0f66c86
2017-05-17 10:46:39 +00:00
Vadim Yanitskiy 1cd9991cf6 utils/osmo-sim-test.c: strip unused variables
Change-Id: Id577d9df5a814ad5aa00e1d04c4790d75d17ad7e
2017-05-17 10:15:09 +00:00
Vadim Yanitskiy 4c3e4ea305 gsm/gsm0411_smr.c: strip unused variable
Change-Id: I53f69913907588c45a9661c4e86e1bfb57a2418f
2017-05-17 10:15:09 +00:00
Philipp Maier 18d49d694f l1sap: Add frame-number to measurement indication struct
The distribution of the channel measurement calculations over
multiple timeslots (continous calculation) requires to keep
track of the frame number in struct info_meas_ind_param

Change-Id: I8c783b4a92ae2c3cc5d17936a146eb49d47eac37
2017-05-17 09:08:15 +00:00
Harald Welte 0047602435 timer: use timerclear() rather than explicit tv_set = tv_usec = 0
Change-Id: I2735fc8d19fd68ef2c14a31e83cb396dc2e05587
2017-05-15 19:00:43 +02:00
Harald Welte 67bdd80a96 stats: Disable stats*.c on embedded targets
Change-Id: I6beb4fcc394ed7d3f8dd7a097b6e998245ecf401
2017-05-15 19:00:40 +02:00
Vadim Yanitskiy ac9e2d8aa5 gsm/tlv.h: fix copy-paste error
Change-Id: Id52ddd8358fd4af1ecc71142deb09f1e237021f3
2017-05-15 12:51:15 +00:00
Vadim Yanitskiy 35b54d12bb fsm_test.c: fix unreachable check
Change-Id: Ic3d5da00f7ece6dbcd4c999187a5748c9331e60f
2017-05-15 12:51:15 +00:00
Harald Welte a5bb2b9586 strrb: Add missing #include to talloc.h
The strrb.c code uses talloc API without using the proper #include.

Change-Id: I4ac485324f40545339d8df6884f1dea319a23648
2017-05-15 13:42:03 +02:00
Harald Welte 20725b9eea gsm0808 + ipa: fix compilation on systems without sys/socket.h
Change-Id: I60f5d4982cd96ab29f9924ec11b46bf56fbfc346
2017-05-15 13:42:03 +02:00
Harald Welte bfe62e5781 libosmogb: Convert to use new endian conversion helpers
Change-Id: I5ed17702cd9487e1cab6bae39802aa11fb6a37b0
2017-05-15 13:42:03 +02:00
Harald Welte 50ef73377c tlv: Add tlvp_val{16,32}be() to get TLV values in unaligned host byte order
Change-Id: I3749e1e4974742bc8c32722e0e998775b5394829
2017-05-15 13:42:03 +02:00
Harald Welte 95871dadbd use osmo_{htonl,htons,ntohl,ntohs}() functions all over libosmocore
This gets us one step closer to fixing the embedded build

Change-Id: I3fc2639b6ade9ab138766987eceab7ec9498fdc7
2017-05-15 13:42:03 +02:00
Harald Welte 3318c657de introduce byteswap.h with osmo_{htonl,ntohl,htons,ntohs}
We need to have an architecture-independend way of endian conversion /
byte swapping functions which will also work on embedded (bare iron)
builds.   Let's introduce osmocom/core/bytesawp.h for this purpose.

Change-Id: Ibc0cc1e36d4ed63a35cf8ceff3af0f26e5ac7a3d
2017-05-15 13:42:00 +02:00
Harald Welte 054667fe15 endian.h: Make it work on 'bare iron' builds (and possibly more platforms)
We can use __BYTE_ORDER__ which seems to be defined by both gcc and
clang/llvm.

Change-Id: Id6821c99e88242126d9697099b1dd92c6212526a
2017-05-15 13:01:01 +02:00
Harald Welte b93ce5afec src/logging.c: Fix EMBEDDED build
We don't enable/build _file_output in EMBEDDED builds, so we shouldn'r
refer to that symbol.

Change-Id: I491aa8ee9d20a96cbb2814700475afe03eb99c9e
2017-05-15 13:01:01 +02:00
Vadim Yanitskiy 391d8746d0 kasumi_test.c: fix incomplete check
Previously the 'passed' variable in test_expansion() was being
overwritten on every call of _compare_mem(), so only the result
of last call influenced the test result.

Change-Id: Ibf3ab453c20c7eeec234b95bfe14b497c572c35f
2017-05-14 20:27:22 +03:00
Max 91dd219b99 Make EARFCN size calculation more robust
* add osmo_earfcn_bit_size_ext() function which allows to specify how many
  EARFCNs we should skip when estimating required bit size for SI2quater
* make old osmo_earfcn_bit_size() into wrapper over newly added function
  and mark it as deprecated

This is necessary to properly estimate necessary space for EARFCNs when
they are spread over several SI2q messages with different index.

Change-Id: I92e12e91605bdab9916a3f665705287572434f74
Related: RT#8792
2017-05-14 08:51:26 +00:00
Daniel Willmann 6959e3c110 gsm_04_08: Add missing GSM cause value
Table 10.5.157 in 10.5.6.6 of 3GPP TS 04.08 is badly formatted. The first
value 0x19 "LLC or SNDCP failure" is in the same line as the heading and has
not been included in the struct_value so far.

Table 10.5.157 in 10.5.6.6 of 3GPP TS 24.008 fixes this formatting issue and
also defines two more values 0x08 and 0x18 which are now added to the struct
value_string.

Change-Id: I5bcc52f739ff0677011d024448afcc2a54869638
2017-05-12 13:53:12 +00:00
Vadim Yanitskiy 13f4762827 configure.ac: fix build on systems without SIMD support
HAVE_AVX2, HAVE_SSE3 and HAVE_SSE4_1 were never defined if CPU
architecture doesn't match the (86*|x86_64*|amd64*) condition.

Change-Id: If0c3128f9768f95c1f5f955db242e71c81384c6c
2017-05-11 15:20:03 +00:00
Max b904091173 doc: fix incorrect return value description
Change-Id: Ieba009273f911bc4217122a6346220aeb29e8bc4
Related: OS#1614
2017-05-10 13:32:49 +02:00
Pablo Neira Ayuso 44f423f117 timer: add osmo_timer_setup()
Add a new function timer function to set up the timer, similar to what
we have in the Linux kernel. This patch also converts existing opencoded
timer setup in the libosmocore tree as initial client of this new
function.

This patch implicitly removes function callback passed by reference that
defeat compile time type validation.

Compile-tested only, but I ran make check that reports success when
testing timer infrastructure.

Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666
2017-05-09 12:10:51 +02:00
Max c65c5b4ea0 vty: cleanup logging functions
* remove unused parameter from logging_vty_add_cmds()
* mark log level descriptors static
* change internal static function int check_log_to_target() to more
  appropriate bool should_log_to_target()
* deprecate log_vty_command_*() from public API as it should only be
  used by logging_vty_add_cmds()

Change-Id: I0e9ddd7ba3ce211302d99a3494eb408907a2916e
Related: OS#71
2017-05-09 09:11:05 +00:00
Max 584f4b69d6 gprs: add value strings for NS PDU type
Add value strings for Service Control PDUs according to 3GPP TS 48.016 §9
and use them for logging.

Change-Id: I0ea3a45f35d68619d4cfa9735ef77abd9f9f0d58
Related: SYS#3610
2017-05-09 09:10:20 +00:00
Max 33c7ba6934 Simplify ctrl cmd lookup
Replace if-else ladder & gotos with single switch statement & explicit
return to make reading code easier.

Change-Id: Ida1b389b571c60c26813cd29e61b3e4423c5df0f
2017-05-08 08:36:50 +00:00
Philipp Maier 85a6af213e gsm0808: fix control flow issue
Coverity Scan reported a control flow issue in line 206:

CID 166898: Control flow issues (DEADCODE)

The second branch of the if statement can not be reached. The
purpose of the second if branch was to filter out zero length
elements if the header states that it is a non extended speech
codec type. This makes no sense, since the header needs at
least one byte.

This patch removes the second if branch, zero length elements
are catched by the already existing zero length check at the
beginning of the function

Change-Id: I89751fc0d598734c64ef1fdced75b7c4fa77c616
2017-05-08 07:35:37 +00:00
Vadim Yanitskiy a8a5819155 configure.ac: check for __builtin_cpu_supports call support
The '__builtin_cpu_supports' is a GCC's built-in function which
returns a positive integer if the run-time CPU supports specified
SIMD feature and returns 0 otherwise. It is required for further
SSE optimization of Viterbi decoder.

This change adds a new check, whether compiler supports this call.
See /gcc/X86-Built-in-Functions.html at gcc.gnu.org for reference.

Change-Id: I5d52cfb3e8fab3eedc0293a2842708cbee0f476a
2017-05-08 02:02:49 +07:00
Vadim Yanitskiy 2c3066e5da configure.ac: add SIMD detection capabilities
This change adds a check whether compiler supports some SIMD
(Single Instruction, Multiple Data) instructions. It is enabled
by default, and can be disabled by configure option --disable-simd.
The check macro is based on the AX_EXT from autoconf-archive:

www.gnu.org/software/autoconf-archive/ax_ext.html

And depends on the ax_check_compile_flag macro:

www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html

Currently only the following SIMD extensions are being checked:
AVX2, SSE3, SSE4.1, but adding others is also possible. All found
extensions are being defined in the 'config.h' header.

Change-Id: Idf8fff984bd936a75c7c307338df88ba4b005817
2017-05-07 23:11:06 +07:00
Vadim Yanitskiy e604ee39cf core/conv: strip unused memalign() call
The alligned memory allocation is only required for SSE, which
is currently unsupported. Moreover, it's better to use dedicated
_mm_malloc() and _mm_free() from xmmintrin.h instead, which are
introduced by Intel specifically for SIMD computations.

Change-Id: Ide764d1c643527323334ef14335be7f8915f7622
2017-05-07 23:10:51 +07:00
Max 409e897df5 Fix broken ctrl commands
Recent changes to libosmoctrl resulted in ctrl comands being broken
because local lookup helper returned incorrect value for ROOT_NODE.

Note: although this commit seems to fix it for me, I'm still not sure
how the logic behind lookup function return values work. Would be nice
to get it documented.

Change-Id: Iddd20602047ebd9be1b668593f5dfa6f1d3e8369
2017-05-03 14:23:45 +00:00
Vadim Yanitskiy 33e03065a5 tests/conv: add GSM 05.03 specific test
This change extends the convolutional code test coverage, adding
the GSM 05.03 specific test vectors, generated by the conv_gen.py.

Inspired by Tom's patch:
http://lists.osmocom.org/pipermail/openbsc/2014-April/007364.html

Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a
2017-04-30 02:59:42 +07:00
Max f74cfd35ac Add SW Description (de)marshalling
* data structure representing 3GPP TS 52.021 §9.4.62 SW Description
* function to serialize it into msgb
* function to deserialize it from buffer
* functions to extract/estimate buffer size for SW Description
* test harness (partially taken from OpenBSC)

There are several similar functions to deal with SW Description in
OpenBSC, there's also need to use similar functionality in
OsmoBTS. Hence it's better to put the code into common library with
proper tests and documentation.

Change-Id: Ib63b6b5e83b8914864fc7edd789f8958cdc993cd
Related: OS#1614
2017-04-28 08:45:09 +00:00
Harald Welte 8a4895c0e5 Uninitialized variable in ipa_ccm_make_id_resp_from_req()
We are allocating a buffer on the stack without initializing it, and
then passing it into ipa_ccm_make_id_resp().  There is no real danger
from this, as the buffer is only uninitialized if num_ies is 0, but
let's memset() it for good style

Change-Id: If5761a47b8cba73ddcc02a88cfa5c87c1970c04e
Fixes: coverity CID#167040
2017-04-27 10:25:10 +02:00
Harald Welte 0b2f7153f2 control_if: Don't use magic number '5' when allocating vector
We have a proper constant for this (_LAST_CTRL_NODE), so let's use it.

Change-Id: I46275e644166156cb665da70d2964008f1c6cd88
2017-04-27 09:50:51 +02:00
Harald Welte 31c0fef2fd control_if: Add control interface commands for FSMs
This allows programmatic access to introspection of FSM instances, which
is quite handy from e.g. external test cases: Send a message to the
code, then use the CTRL interface to check if that message has triggered
the right kind of state transition.

Change-Id: I0f80340ee9c61c88962fdd6764a6098a844d0d1e
2017-04-27 09:50:47 +02:00
Harald Welte f85861d6eb control_if: Add helper function for 'local execution' of control command
Sometimes (particularly when testing), we may want to parse+execute an
arbitrary control command simply form a string buffer, rather than from
a msgb.  Let's add a helper for that.

Change-Id: Iaca748e0d942bb2a1ee7c2776b37485e1439eb0c
2017-04-27 09:50:33 +02:00
Harald Welte 79c137c654 control_if: Add API to initialize control interface without TCP port bind
When executing test cases, we don't want to bind to a local TCP port, as
we cannot make assumptions as to which ports are actually free.

Change-Id: I5717f9dd92d1f143f069cecd4b4c8ba3d03b25f8
2017-04-26 13:47:06 +02:00
Harald Welte d6b1f85fd8 ctrl: Allow installation of additional node lookup helpers
The existing code assumes that the main application knows about all
control command nodes and can thus present one lookup function.

As libraries are getting their own control interface handling, this
is too restrictive, and we need a way how library code can dynamically
register more node lookup helpers.   We can now do this by means of a
ctrl_lookup_register() function.

Change-Id: Ib69908d1c57f5bb721d5496e3b4a5258fca450e3
2017-04-26 09:22:19 +00:00
Thorsten Alteholz a81055db1d fix spelling in API docu, command reply, logging, descriptions
sections: ctrl, gb, gsm, vty

Change-Id: Iac211b5cd8504da36b699777b95a2448dd7c3e70
2017-04-23 14:34:18 +00:00