Commit Graph

216 Commits

Author SHA1 Message Date
Harald Welte 0e194d4cd7 intf_line: Ensure unique rate counter group indexes
When we have multiple interfaces, we cannot simply use the line->id
as rate counter group index, but should use a combination of interface
id and line id.

Change-Id: I515c1f39285489845f88c3403ebf16835571e154
2022-03-28 12:13:08 +02:00
Harald Welte 620d7d3586 cosmetic: curly braces around multi-line blocks
This reflects our general coding style.

Change-Id: Ibf8ebe4c9fdde2bd66ce6239c8eca833e71fc815
2022-03-28 12:13:08 +02:00
Harald Welte 2819d3fb79 intf_line.c: Make e1d_find_intf_by_usb_serial safe for empty string
Avoid segfault in case the empty string is passed as serial_str.

Change-Id: Ia69912cb714441415d8decd68890d1b97b77132d
2022-03-28 12:13:08 +02:00
Harald Welte 591249a3c2 cosmetic: Remove extra empty newlines from end of intf_line.c
Change-Id: Ie1e193c3d851871c9c96394eb19f5b99c09913f9
2022-03-28 12:13:08 +02:00
Harald Welte 42c443f42d e1d.h: add #pragma once
all other header files already have it in place.

Change-Id: Ia7a7856563c2c9d422b73fdc431e0ea4d456f9aa
2022-03-28 12:13:08 +02:00
Harald Welte f18dcc706f usb: rename 'size' to 'len' in callback functions
What we are passing is not the [underlying] size of the buffer, but
the length of the valid data in them.

Change-Id: I8ce91527351a56c103bd077c9565be2a81d175ac
2022-03-27 17:14:49 +02:00
Harald Welte 8e3924db25 Proper libusb error reporting in all error paths
... using libusb_strerror().

Change-Id: Id205f1cf1bbccd83b789f8ab31fe1d5d4e1fb8a9
2022-02-07 18:38:08 +01:00
Harald Welte 7bc8404f63 GPS-DO support for icE1usb hardware
This adds support for monitoring the GPS-DO that is built-in to the
icE1usb device.  It assumes a very recent firmware with GPS-DO control
moved to a separate USB interface, i.e. after osmo-e1-hardware.git
Change-Id Icd6555a14896c38626fb147b78af44ff719f2254 is merged.

Change-Id: If5e2a6b2dae0290ce3186009e68f618049ebf5ff
2022-02-07 18:38:08 +01:00
Harald Welte f5362e9217 Allow configuration of interfaces/lines via VTY
So far, osmo-e1d automatically opened all compatible icE1usb devices
and all E1 lines on those interfaces.  Let's allow for 'interface' and
'line' configuration in the VTY.  USB devices can be identified by
their serial number string.

If a given device (== E1 interface)  has a VTY configuration, then only
those E1 lines with VTY configuration opened.

For each Line (icE1usb or vpair), the mode (channelized/superchannel)
can also be set via VTY.

Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77
Closes: OS#5400
2022-02-01 17:17:31 +00:00
Harald Welte ef69fd1a63 e1_{intf,line}_new: Allow caller to specify the numeric identifier
This will be used by the upcoming VTY interface changes.

Change-Id: I9ff80831a3e3e3cb6dae178f8b438a9f3f4747df
2022-01-31 19:51:14 +01:00
Harald Welte 9d6dab8992 update copyright statement
Change-Id: I1b4817207369e572a2b070443475289cc527c317
2022-01-31 14:49:31 +00:00
Harald Welte 3fd3df13b5 make rate_counters work
if we don't call rate_ctr_init(), the rate counter internal timer will
not tick,a nd we will never get the per-s/per-m/per-h averages.

Change-Id: Ib5b66c72079330ac161756bcf562d27536d7ce44
2022-01-31 14:49:26 +00:00
Oliver Smith e53eed98ea checkpatch.conf: new file
Related: OS#5399
Change-Id: I4bd109009cbe16f313e19ab78bd5fbcb13b0f656
2022-01-18 09:44:03 +01:00
Harald Welte c6246b654b usb: Use libusb_status_str when logging INT EP error
Change-Id: I3a3cd88ba35796740dbd399eb618617941dae54a
2022-01-10 11:00:06 +01:00
Harald Welte a3ff181a82 usb: Print failed USB isochronous packets
Change-Id: Ib6fcf46be40d47817632ccae4e742d6cf7340cda
2022-01-10 11:00:03 +01:00
Harald Welte 3fff68cbf8 cosmetic: Adhere osmocom coding style in for-loops
We either have to bring osmo-e1d in line with other osmocom projects,
or we'd have to disable the linter in jenkins.

Change-Id: I74ab20b22118d471dcdb60d1b9681ab62eb13d51
2022-01-09 23:39:42 +01:00
Sylvain Munaut 7cc8a7b806 contrib/e1-prbs-test: Delay the TX pipe fill data until first RX
There is non negligible time between the moment init_timeslot is
called and the moment when we get the first RX (which is when
we start sending out data at the same rate we RX it). And those
1024 byte were borderline not enough to not underflow.

By delaying the 1024 byte pre-fill until we get the first RX,
we ensure the time that pre-fill covers is more consistant and
less dependend on whatever the app/scheduling does during the
init phase.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ic1c93fd138073a75830dc16bb41c4541e68eef90
2022-01-09 15:09:11 +01:00
Sylvain Munaut 3729f8f90e mux_demux: In RAW mode, fill with dummy until first TX
Until the remote side sends the first byte, we send fill
data since it can take it some time after the mode change
and the file descriptor is open for data to show up.

Previously due to a bug, the warning about short read was
not printed, but now that it's fixed, you get a bunch of
fairly "useless" warning at the beginning of the timeslot.

This fixes that since reported data by _e1_tx_raw is "faked"
until the pipe is active. (Fill data is actually added upstream)

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Iaa6268e9b4a7bce5ea3027a29c48c147499373be
2022-01-09 15:09:11 +01:00
Sylvain Munaut e945a897f7 mux_demux: Shuffle functions around for consistency
No functional changes, just making things a bit more organized
for the next patch adding an _e1_tx_raw.

The order after the patch is :

_e1_tx_hdlcfs
_e1_ts_read
_e1_line_mux_out_channelized
_e1_line_mux_out_superchan
e1_line_mux_out

_e1_rx_raw
_e1_rx_hdlcfs
_e1_ts_write
_e1_line_demux_in_channelized
_e1_line_demux_in_superchan
_e1_line_demux_in_ts0
e1_line_demux_in

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I2ced3a5ba3cf3cc1f212d8f3e46cfefa15e4af0c
2022-01-09 15:09:11 +01:00
Sylvain Munaut 0d2a42bc12 usb: Add warning for error during interrupt transfers
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Id4d2c95a2d934700f817e971aa4ce29e4bd85675
2022-01-09 11:43:03 +01:00
Sylvain Munaut 73d7184088 Fix a bunch of warning raised by the new build warning options
A lot of them are related to signedness or type range limitation.
A lot are not actual issues and work find in practice, but a few
lead to actual bad behavior.

This makes all the conversion explicit to mark intent.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I992b9bc51659e85966651b1146091501b8f149f5
2022-01-09 11:43:01 +01:00
Sylvain Munaut 35a9cf0b99 build: Increase warnings
Go with -Wextra but removing some of the obnoxious options it brings with
it.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Iaafd35ba39e272d5900b31b14d2651e0ecb8a84a
2022-01-09 11:42:41 +01:00
Sylvain Munaut 3bea0bcedc e1d/usb: Use wMaxPacketSize to know maximum number of frames to send
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I9595cba39377e45303d41a06753861bf72d5a93a
2022-01-06 16:10:28 +01:00
Sylvain Munaut 4b1226f5ac e1d/usb: Limit feedback EP transfer size to 3
Newer descriptors have the max packet size set to 3 to save on
isochronous bandwidth.

By specs, the feed back endpoints transfer are 24 bits anyway,
so no point is using anything larger.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I09e259db539e62571fd17fc16ffaa317564ba257
2022-01-06 16:10:26 +01:00
Harald Welte d1d6d93f2e Add support for icE1usb RAI interrupt error flag
In osmo-e1-hardware.git Change-Id Ic4f57cf79bd32cf75f81ef3073cb8d4a2d1857d8
we added support for passing RAI (remote alarm indication) as a flag via
the USB interrupt messages; let's add support for this here.

osmo-e1d already internally parses TS0 to determine the same
information, and we have to keep this for backwards-compatibility with
older firmware builds.  But maybe at some future point we can remove
our own TS0 scanning code here and rely on the USB device to inform
us about remote alarms.

Change-Id: Ie1994968e792c37f9272b9854547db95a41cab5b
2022-01-02 13:04:09 +01:00
Harald Welte fb1293ccea Use the error counters for remote alarm + remote CRC error
Some time ago we added various error counters, but for two of them
we missed to actually ever increment them at all.

Change-Id: Ieb83a2e2e83e334c543bee83726f04f83b19227a
2022-01-02 13:02:37 +01:00
Harald Welte d7aae90890 Bump version: 0.2.2 → 0.3.0
Tag a new version due to the 'EOF detection' and
'HDLC overflow' fixes committed sicne 0.2.2.

Change-Id: Icedc836a345f22ab7b1ccd274d57867a7018c08e
2022-01-01 15:42:20 +01:00
Harald Welte 890e153170 update ice1usb_proto.h to current master
Copy from firmware source code repo at
https://git.osmocom.org/osmo-e1-hardware/tree/firmware/ice40-riscv/icE1usb/ice1usb_proto.h
as of d376b2e852fbf26a60ac4d6f66e54bb85f0b7204

Change-Id: I8f7b9462482421993e3516aa9d0794bb8076b65b
2021-12-31 20:35:19 +01:00
Harald Welte 8ddb22f8c6 e1d: Add watchdog timer to detect dead lines / USB devices
We just found a bug in icE1usb (likely firmware) which was hard to find
as there was zero notification from osmo-e1d that it actually never
received any data from the icE1usb hardware/firmware anymore.

Change-Id: Id22e4110b9067f50b1818eb12295b2d4eb9cdc12
2021-12-31 17:20:32 +01:00
Harald Welte d4700da1e8 e1d-ts-pipe: Don't write more HDLC bytes than e1d supports
This avoids truncation and the following error message when operating
in HDLC-FCS mode:

<0001> mux_demux.c:91 (I0:L0:T16) Truncated message: Client tried to send 320 bytes but our buffer is limited to 264

Change-Id: I836d8b98ce5b831b0498c4650263ec3b3d4f2c45
2021-12-31 16:47:15 +01:00
Harald Welte 50b121cfc4 Introduce a #define for the maximum HDLC buffer size (264)
The purpose of turning the magic number into a #define is to allow
clients to use it.

Change-Id: I9281a4cd85d79823d06860ffaaa09b6d67bc0de3
2021-12-31 16:47:12 +01:00
Harald Welte 383782396f e1d: reliably detect EOF (HDLC-FCS mode)
This patch makes e1d reliably detect EOF on client sockets while in
HDLC-FCS mode.

Change-Id: I0260360643f723f7c721ae67c47dce8df7778694
2021-12-31 16:46:06 +01:00
Harald Welte d8e37c8b56 e1d: reliably detect EOF in _e1_ts_{read,write} (RAW mode)
This allows us to reliably detect client disconnection at least in
the case of RAW mode channels.  Even with this patch applied, e1d
still fails to reliably detect client disconnect on HDLC-FCS channels.

Change-Id: Ifb8b91d39b394f9c10c859f3adac85ea47b7653f
2021-12-31 16:45:54 +01:00
Pau Espin 932c57e468 Bump version: 0.2.1.5-5e0d-dirty → 0.2.2
Change-Id: I640c4503260e50d412a8c66260c61f9224fef8d2
2021-11-16 18:10:15 +01:00
Harald Welte 5e0dfdcfe4 make compile-time default logging configuration less verbose
As Keith pointed out we shouldn't spam the stderr with debug level
logging by default.

Change-Id: I909affb3b798c13950f95628275a6ec3a38c76ca
2021-11-12 21:34:34 +01:00
Pau Espin 74fa8ba7a5 gitignore: Add configure~
Change-Id: Iadcf4db79eef567781459cee5e7487984f3cfc54
2021-06-04 18:05:56 +02:00
Pau Espin 6a3a2aa9a7 Use new stat item/ctr getter APIs
Change-Id: Ib1bf9a6e5d2743522f888e7ef4815283b82ef809
2021-06-04 18:05:25 +02:00
Harald Welte ee9d62bb51 ctl: properly set the timeslot mode in E1DP_CMD_TS_QUERY
Change-Id: Ie7bfec19e37f748d44f4a90d296ea232bbd76b12
2021-05-10 23:33:54 -05:00
Harald Welte a82fe56aea e1d-prbs-test: Initialize libosmocore logging
Fixes the following crash when libosmo-e1d wants to log something:

ERROR: osmo_log_info == NULL! You must call log_init() before using logging in log_check_level()!
Assert failed osmo_log_info logging.c:299
backtrace() returned 13 addresses
/usr/local/lib/libosmocore.so.17(osmo_generate_backtrace+0x1c) [0x7ff4ed29d6cf]
/usr/local/lib/libosmocore.so.17(+0x263c7) [0x7ff4ed29d3c7]
/usr/local/lib/libosmocore.so.17(osmo_panic+0xe0) [0x7ff4ed29d4ac]
/usr/local/lib/libosmocore.so.17(assert_loginfo+0x74) [0x7ff4ed298f57]
/usr/local/lib/libosmocore.so.17(log_check_level+0x1e) [0x7ff4ed29b091]
/usr/local/lib/libosmo-e1d.so.1(osmo_e1dp_send+0xf2) [0x7ff4ed2727a2]
/usr/local/lib/libosmo-e1d.so.1(+0x19d4) [0x7ff4ed2729d4]
/usr/local/lib/libosmo-e1d.so.1(+0x1c37) [0x7ff4ed272c37]
/usr/local/lib/libosmo-e1d.so.1(osmo_e1dp_client_ts_open+0x1d) [0x7ff4ed2730ed]
./e1-prbs-test(+0x1841) [0x55e00daeb841]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7ff4ed0a60b3]
./e1-prbs-test(+0x192e) [0x55e00daeb92e]
Aborted

Change-Id: Ia305b008711c15383c84f7cf2acedd20b568ef8a
2021-04-04 11:16:58 +02:00
Harald Welte 949c237963 Bump version: 0.2.0.1-4fea-dirty → 0.2.1
Change-Id: Icf86d5df9705c13b75970e2950ad95614e545ef0
2021-03-26 09:34:49 +01:00
Harald Welte 67b6f40201 e1d: fix ASSERT during "write terminal"
There was some wrong ordering in config_write_e1d() regarding
resolving the vpair 'peer' devices.  We can only call
e1d_vpair_intf_peer() _after_  we have established that the
given interface actually is of type VPAIR.

Assert failed intf->drv == E1_DRIVER_VPAIR vpair.c:96

Change-Id: If494d77ed1df5cda655d3b4a60868154dc2b355e
2021-03-26 09:29:15 +01:00
Harald Welte 4fea7a7083 add README.md describing what this repository is about
Change-Id: I9ef46d8fa70cedaa8af6a9895422f4e60d701266
2021-03-21 22:51:55 +01:00
Pau Espin 807364dcae Bump version: 0.1.1.33-4292-dirty → 0.2.0
Change-Id: I5353aee666d88e3d439e465dd06e34a9ea4d8b29
2021-02-24 14:07:28 +01:00
Oliver Smith 42922ef334 configure.ac: set -std=gnu11
Change-Id: Ib2356c2158b5aaa27cb4692de0f92d09d0bfca06
2021-01-27 17:47:27 +01:00
Harald Welte 1e30f0dab7 Add new "osmo-e1gen" program.
osmo-e1gen is a program that re-uses large parts of osmo-e1d, but whose
main purpose is to generate a variety of error conditions in order to
test a remote E1 implementation.

Instead of using the automatisms of the icE1usb transmit IP core, it
switches it to transparent mode and uses a host-software based E1 framer
"osmo_e1f", over which we have more control than the firmware.

Change-Id: I53a86d6730eb76a9cff9eb3f4786139015c91230
2021-01-05 23:46:05 +01:00
Harald Welte 31ac0bea55 Evaluate received E and A bits in TS0
Related: OS#4917
Change-Id: I7e1c919518b3418e973b7ae5bedd5a6dd1c2adec
2021-01-05 23:46:02 +01:00
Harald Welte 868c94b704 vty: export vty_e1d + move e1d_vty_node to header file
This will be required by osmo-e1gen

Change-Id: I5be0278bc07aadd154fc54a74b08fc7e3b5d6483
2020-12-20 11:46:19 +01:00
Harald Welte e07bbb5037 Move e1d_find_intf + e1_intf_find_line to intf_line.c
Those are generic helper functions not really related to the ctl
interface.

Change-Id: Ibbda172aa425ca1e4702bacc7e595cd73a52929d
2020-12-20 11:46:19 +01:00
Harald Welte 1923b4d832 move usb.c function declarations to newly-created usb.h
Change-Id: Icab91d73e37119960ca3c953bf91c2ec9d821311
2020-12-20 11:45:54 +01:00
Harald Welte d270f73d66 usb.c: Mark _e1_usb_open_device() as static
Change-Id: Ic4ac2b77f12479daa52392cc31ca1e7d9ed96567
2020-12-20 11:45:44 +01:00