Commit Graph

1055 Commits

Author SHA1 Message Date
Harald Welte 768838154b trunkdev: Implement DAHDI_MAINT_{LOCAL,NETWORKPAYLOAD}LOOP
Using those maintenance modes we can test the local (DAHDI channel)
and remote (trunkdev) sides indepdendent from each other.

Change-Id: I12cf9647fb6def38865aaac8ad6bbb58ebf7b5fd
2023-08-09 15:55:44 +00:00
Harald Welte c4cfb4a722 Flush DAHDI->trunkdev FIFO at open time
If we don't do this, we always have a full FIFO at the time userspace
opens the trunkdev, adding latency for no good reason.

Change-Id: Ifbda3766309cc7d6be485073e36607bdd6742f3a
2023-08-09 15:55:38 +00:00
Harald Welte 588281bff0 Introduce virtual DAHDI trunk device
This virtual trunk device is a new character device. Contrary to
the per-channel devices, this is a per-span device for virtual E1
spans.  Userspace reads and writes 32-byte E1 frames on it.

ioctl's are added to create and delete such virtual trunk devices
at runtime.  Each virtual trunk device is limited to one span.

Opening trunkdev is similar to opening channels via /dev/dahdi/chan
works:  All users open the same generic device node but then issue
an ioctl to specify which (named) trundev they actually want to open.

This avoids having to dynamically register minor device ids, creating
device nodes, etc.

The trunkdev is in RED + LOS alarm after creation.  Only once a userspace
process opens the E1 frame side, those alarms cease.

Change-Id: Iffd9a1a09d835b29927acd374364cab56745fb74
2023-08-09 15:55:31 +00:00
Jaco Kroon 4d769978ff xpp_usb: Fix for 32bit architectures: use div_s64()
Change-Id: Ib5cef80c018f800cc0a0cd08a51d6cb7afd584c6
2023-07-29 17:38:10 +02:00
Oliver Smith a210405427 contrib/jenkins: set -Wno-error=address
After changing our CI environment to build with Debian 12,
GCC 12.2.0-14 fails to build linux-dahdi with Werror (default since
linux 5.15). Set -Wno-error=address to not fail the build.

/build/drivers/dahdi/xpp/xbus-core.c:116:13: error: the comparison will always evaluate as 'true' for the address of 'label' will never be NULL [-Werror=address]

/build/drivers/dahdi/dahdi_dynamic_ethmf.c:538:34: error: the comparison will always evaluate as 'true' for the address of 'name' will never be NULL [-Werror=address]

/build/drivers/dahdi/wcte13xp-base.c:2704:13: error: the comparison will always evaluate as 'true' for the address of 'xb' will never be NULL [-Werror=address]

Fixes: OS#6098
Change-Id: Ifc8fb605cb8e0de70e5556b127e22533cbe24c37
2023-07-17 14:02:54 +02:00
Harald Welte 2f9309267d compatibility with class_create API change in 6.4-rc1
Linux kernel 6.4-rc1 has an API change for the class_create() function.

See upstream kernel git commit 1aaba11da9aa7d7d6b52a74d45b31cac118295a1

Change-Id: I5f7d25aa7516c470b943b9e8dfba20ca4206e378
2023-06-06 14:51:55 +02:00
Harald Welte bcc30fe214 kernel 6.4 API change in DEFINE_SEMAPHORE
This works around build failures with kernel >= v6.4-rc1 where
the DEFINE_SEMAPHORE macro is adjusted in upstream kernel commit
48380368dec14859723b9e3fbd43e042638d9a76

Change-Id: I752c903c8a0345af6e51a996d064c9d629578ab4
2023-06-06 14:51:55 +02:00
Harald Welte 36b8ad4d27 Fix jenkins.sh failure for kernels >= 6.3.0
In >= 6.3.0 the default for how modules are built in absence of
vmlinux.o or Module.symvers due to a change of the modpost execution.

See linux kernel git commit 5573b4daa26a0cf15aa0fecd7f1be16e0b6157bc

As our build verification *just* builds the dahdi modules without
building the entire kernel, we need to enforce the legacy behaviour
by adding KBUILD_MODPOST_WARN=1 to the command line.

Change-Id: I7206f1daed8ff1e7fcd4894bc24e5ef4d4590358
2023-06-06 14:51:49 +02:00
Harald Welte c37d6e3c2d Support kernel >= 6.3.0 (bus_type.uevent() const struct device)
linux kernel commit 2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6 modifies
the struct bus_type.uevent() argument from 'struct device *' to
'const struct device *'.  Let's adjust our code to support that.

Change-Id: I0c416d8fa8d7d0081fdfec6325971d6de9f8d239
2023-06-06 14:29:58 +02:00
Harald Welte ae5aa32fe0 kernel 6.1 API change: netif_napi_add() uses weight==64 by default
Change-Id: I7e70659e43c930a4c220eaef29cfb4e8d7a6eb0d
2022-11-30 16:57:16 +01:00
Martin Hauke 783c356196 Revert "Remove support for wctdm800, wcaex800, wctdm410, wcaex410."
This reverts commit:
* a66e88e666

Tested with
* Digium Wildcard TDM800P

Change-Id: Ie143df9873aa84ade066fdd04b3748a849a13fc2
2022-05-01 09:24:43 +00:00
Martin Hauke 5a749d7e86 wcb4xxp: Add support for Swyx 4xS0 SX2-Express QuadBRI
This adds support for the PCIe-variant (-Express) of
the Swyx 4xS0 SX2 QuadBRI.

Change-Id: Id8adeae8545c06694c4d3f4a4939d4842f2c4651
2022-04-30 15:26:20 +02:00
Martin Hauke fdb4d807f5 Revert "Remove support for all but wcb41xp wcb43xp and wcb23xp"
This reverts commit:
* 329cb229cd3f1d252872b7f1924b6e3be941f7ad
* 75620dd9ef

Tested with
* Junghanns QuadBRI ISDN PCIe
* OpenVox B400P PCI

Change-Id: I5a2eddf597c6f5c47922ecafc72c43f3a312f005
2022-04-30 15:24:04 +02:00
Harald Welte 61b449a153 dahdi-sysfs-chan: Fix potential NULL pointer deref
Sometimes it is useful to look at compiler warnings:

dahdi-sysfs-chan.c:384:17: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]

And indeed, we could have de-referenced a NULL pointer here.

Change-Id: I4274e7a92ca6ee7e92c6adb713fb89ffe31b4c72
2022-04-24 19:43:23 +02:00
Harald Welte 5b4206edf3 wctc4xxp: Use __dev_addr_set() on kernels >= 5.15
The address list has been converted to a tree, so netdev->dev_addr
is now const and must not be written directly.  The __dev_addr_set
helper can be used for this.

Change-Id: Id7b71164dfe7772b68e86cb12ac0e0974fec1498
2022-04-24 19:43:23 +02:00
Harald Welte 69b223e58d Fix -Wimplicit-fallthrough=5 warnings
Modern Linux (since 5.4) builds with -Wimplicit-fallthrough=5.  On some
environments (notably Debian buster) this is even an error, so building
dahdi-linux will fail.

Let's add the proper 'fallthrough' annotation of
linux/compiler_attributes.h and add a backwards-compatibility definition
for older kernels.

Change-Id: I3507876d90dd882b95c22ece51e8620ad6f0bd08
2022-04-24 19:28:34 +02:00
Harald Welte c61d75d80e wcte13xp: Fix missing break statement when setting J1 line mode
Change-Id: I776812d9fc4d8cb1140555e70a3480bdaf0aaaaf
2022-04-24 19:23:43 +02:00
Harald Welte ad31fbd8b4 icE1usb: Fix inverted logic for clock timing source
The 'struct dahdi_lineconfig.sync' parameter originates from the
'timing' field of system.conf.  dahdi_cfg passes it via the SPANCONFIG
ioctl into the kernel.

The DAHDI docs say:
> source of the master clock. If you choose 0, the port will never
> be used as a source of timing. This is appropriate when you know the
> far end should always be a slave to you.

So if '0' we should use the local clock, and if > 0, the recovered
remote clock.

Thanks to Christoph Lauter for pointing this out.

Change-Id: If35a5a52c094129c342d0f658f496b488d1826ad
2022-04-24 18:06:56 +02:00
Harald Welte 57dbc69bd7 Fix NULL pointer dereference for pseudo channels
pseudo channels are characterized by the fact that they have their span
member set to NULL.  This is illustrated by the is_pseudo_chan()
function.

However, when using RXMIRROR/TXMIRROR, __putbuf_chunk() is called not
just on the real channel, but also on the mirror (pseudo) channel.

Hence, __putbuf_chunk() and friends must not dereference the ->span
member without first checking that this channel actually does have
a non-NULL span assigned.

I originally thought that those unconditional de-references must have
been introduced after the RXMIRROR/TXMIRROR was merged - but checked the
git history and it seems like the bug has been present ever sicne
this functionality was merged in 2010 in commit
9090c6fcd2

Change-Id: I747a696c9a5865c11461b6357a10346a8d0d1621
Closes: OS#5531
2022-04-24 18:06:56 +02:00
Harald Welte 0b4d75a504 icE1usb: avoid system hang if USB transfer submission fails
If one of the isochronous or the interrupt EP URB cannot be submitted,
we should clean-up properly and avoid hanging the dahdi_cfg process
at 100% CPU itilization in an un-killable state.

Closes: OS#5477 (https://osmocom.org/issues/5477)
Change-Id: Ie6f7f11a64fae0d8c2b7c8ae90df886f2eb8f0c2
2022-04-24 18:06:56 +02:00
Harald Welte 13c4ed7c41 enable PPP and DAHDI_MIRROR by default.
There's not really any reason to disable those, from what I can tell.

Change-Id: Ib03074062ada7b6da485afac53b1550d31f1a5ca
2022-04-24 18:06:56 +02:00
Manawyrm b93c2c31f0 readme: Add info about the fork, list of added drivers
Change-Id: I54d3000d4535b9279f53a8c30870e897bdcf0f91
2022-04-24 18:06:56 +02:00
Manawyrm be86d72b54 zaphfc: Port support for HFC-S cards
This ports the current zaphfc driver from the Debian bullseye patchset.

Change-Id: Ifd09d82ea2b6d6245207609da849350db45d91f6
2022-04-24 18:06:56 +02:00
Harald Welte 8f44d72c90 icE1usb: GPSDO status support in sysfs
* ability to read GPSDO related bits via sysfs and ioctl
* ability to set GPSDO mode via sysfs
* show firmware build during driver start and expose it to sysfs

Change-Id: I7bc7daa4738b1db37fdd67945d7e976e2581b417
2022-04-24 18:06:56 +02:00
Harald Welte 27cf923e3b icE1usb: update ice1usb_proto.h to firmware 0.2-8
git revision cac342af6bccc9820a8617f900afaf663ad608ed of
https://git.osmocom.org/osmo-e1-hardware

Change-Id: I1423531470a1c9165d713108fb6a87ff47ff6e29
2022-04-24 18:06:56 +02:00
Oliver Smith eac30422b0 contrib/jenkins.sh: new file
Build the kernel module against a given linux tree. This script will be
used in CI at jenkins.osmocom.org.

Related: OS#5407
Depends: docker-playground Id72d19ad08681cd7cb3194de2226292f19e96df5
Change-Id: I904ab66a1ecd72492642ac2cc4cb102c7283c590
2022-04-24 18:06:56 +02:00
Shaun Ruffell 02420a2d61 vpmadt032: Create .o.cmd file for the shipped object file.
Kernel version 5.8, in commit "modpost: use read_text_file() and
get_line() for reading text files" [1] made it an error if the .o.cmd
file is missing. However, this file is not generated for shipped .o
files.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=70f30cfe5b892fcb7f98e7df72ed6ccfe3225628

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Change-Id: I06d201bcd07b35cb41c8c4a8467bcad6471c431a
2022-04-24 18:06:56 +02:00
Harald Welte 6e31aa61af icE1usb: Use USB_CTRL_SET_TIMEOUT (5s) instead of hand-coded 1s
This seems to be the kernel default for CTRL request timeout,
let's use it here.

Change-Id: I7b7c1a2b13f61372e839e34a376e66c91190bdb3
2022-04-24 18:06:56 +02:00
Jan Engelhardt 3f5debfd4e How did this ever work... stdbool.h is not in the kernel.
Change-Id: I36438e35bb99325e1ac86b68c1746670a9851e4a
2022-04-24 18:06:56 +02:00
Harald Welte cf2da75c87 icE1usb: Don't silently ignore startup errors on re-configuration
If an already-active line gets reconfigured, we implement this by
a shutdown followed by a startup.  However, the startup could fail,
which should make the spanconfig return the error code.
2022-04-24 18:06:56 +02:00
Harald Welte e4bf489c64 icE1usb: raise NOTOPEN alarm if 'startup' fails
This is what happens if there is insufficient isochronous USB bandwidth
to open a port: The STARTUP ioctl fails.  However, as the prior
SPANCONFIG ioctl succeeds, the line apears up with no alarms.

So let's set the NOTOPEN alarm whenever there are errors in STARTUP,
to give a clear indication to the user the port could not be opened.
2022-04-24 18:06:56 +02:00
Harald Welte d5935652ed icE1usb: Don't consider altsetting with no endpoints as "ON"
find_altsetting_on() must not only find an altsetting with no
zero-sized endpoints, but must also make sure there actually
are endpoints.

This enables compatibility with icE1usb firmware >= 0.1-43-g9674436
2022-04-24 18:06:56 +02:00
Harald Welte 6e714c9268 wcte11xp: Fix BLUE (AIS) alarm detection
The XAIS bit to check in the FRS0 register is at 0x40, and not 0x4.

If only the original authors had the wisdom to use #defines for those
bits, and re-used those bits across the drivers (wct4xxp, wcte43x
and wcte13xp get this right!).
2022-04-24 18:06:56 +02:00
Harald Welte 34146a35cc icE1usb: Add support for reporting remote alarm (RAI) as YELLOW alarm
In osmo-e1-hardware.git Change-Id Ic4f57cf79bd32cf75f81ef3073cb8d4a2d1857d8
the icE1usb firmware gained support for reporting the E1_ERR_F_RAI flag
via USB interrupt transfers.  Make use of that to report YELLOW alarm
via the usual DAHDI alarms infrastructure.
2022-04-24 18:06:56 +02:00
Harald Welte a4168c8290 icE1usb: support for reporting CRC and alignment errors via DAHDI 2022-04-24 18:06:56 +02:00
Harald Welte f21eeccb98 icE1usb: Support TX configuration (CRC4 on/off, loopback, timing source)
This adds support of configuring the icE1usb TX configuration via the
standard DAHDI mechanisms.
2022-04-24 18:06:56 +02:00
Harald Welte 4f5378b265 icE1usb: Support reporting of RED alarm via DAHDI infrastructure
We get loss-of-framing and loss-of-signal notification via USB interrupt
transfers.  Let's make use of this information to tell the DAHDI core
[and ultimately the user] about this.
2022-04-24 18:06:56 +02:00
Harald Welte 9e20495082 icE1usb: 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
2022-04-24 18:06:56 +02:00
Harald Welte 2985596a8a icE1usb: Fix span re-configuration after first start
Before this commit, we used to "lock up" the E1 span on every subsequent
span re-configuration from userspace.  This typically happens when the
user calls the `dahdi_cfg` userspace utility.  As normally this only
happens once at system start-up, this bug was only discovered now.

Closes: OS#5379
2022-04-24 18:06:56 +02:00
Harald Welte 3c99c56af3 Add Osmocom icE1usb driver
The Osmocom icE1usb is a modern, software-defined open hardware and
open source firmware design for a USB E1 interface.  You can find more
information at https://osmocom.org/projects/e1-t1-adapter/wiki/IcE1usb

The hardware design can be found at https://git.osmocom.org/osmo-e1-hardware

The FPGA gateware and associated embedded firmware is hosted in the same
git repository. Some parts are in submodules (be sure to use recursive
clone)

This DAHDI driver allows t lothe use of the icE1usb just like any other
E1/PRI interface device supported by DAHDI.  When using this DAHDI
driver, osmo-e1d most not be used.  The DAHDI driver is a replacement /
alternative for osmo-e1d.
2022-04-24 18:06:56 +02:00
Harald Welte 24edb600f8 Introduce ioctl() for simulating alarms under userspace control
For automatic testing scenarios, it is very useful to be able to
artificially create line alarms.  This allows testing of the whole
stack through DAHDI itself, DAHDI-interfaces in applications and
actual applications.

It introduces a new DAHDI_SIMULATE_ALARM ioctl() whcih has to be
issued on /dev/dahdi/ctl and which can be used to set or remove
any simulated alarms on the given span.
2022-04-24 18:06:56 +02:00
Harald Welte 1ccd93a80c DAHDI_NET: Report alarms as lost carrier to net_device
It recently occurre to me that for some strange reason the line/link
status of the E1 span was not reflected in the network device link
status.  This is odd and leads to strange behavior.

In general, it is assumed that a net_device only exhibits LOWER_UP
if there actually is a physical connection.  If you disconnect an
ethernet cable, LOWER_UP will be gone.  Same should happen on
DAHDI_NET devices.
2022-04-24 18:06:56 +02:00
Harald Welte a83e60c416 wcte12xp: Add missing 'break' statment 2022-04-24 18:06:56 +02:00
Harald Welte 07c5470c54 adapt te12xp to DAHDI API changes since its removal 2022-04-24 18:06:56 +02:00
Harald Welte 17099c0f46 Revert "Remove support for driver wcte12xp."
This reverts commit 3697450317.
2022-04-24 18:06:56 +02:00
Harald Welte a706f5a1cc adapt te11xp to DAHDI API changes since its removal 2022-04-24 18:06:56 +02:00
Harald Welte a5796d6113 Revert "Remove support for driver wcte11xp."
This reverts commit 3748456d22,
which removed a driver simply becuase Digium proclaimed they didn't
sell a card in 10 years.  That does *not* mean nobody is using those
anymore.

I wish there was more of a community maitaining the DAHDI drivers.
2022-04-24 18:06:56 +02:00
Harald Welte b072070e12 wct4xxp: Fix build without VPM_SUPPORT 2022-04-24 18:06:56 +02:00
Harald Welte cd446e7171 dahdi_config: Enable DAHDI_DYNAMIC + DAHDI_DYNAMIC_LOC
Especially for automatic testing it is quite useful to have virtual
DAHDI spans with a loopback between them.
2022-04-24 18:06:56 +02:00
Harald Welte 1e596bd52a dahdi_config.h: Enable CONFIG_DAHDI_NET 2022-04-24 18:06:56 +02:00