LTE modem ECM mode connection status

We use the usb_net driver to access the internet on our IoT gateways. It drives a Quectel EG25-G LTE modem (the same as in the PinePhone), which is configured to use ECM mode.

To configure the modem we use a small driver which is a Genode native component, which does the same as the option_uart on linux.

The individual parts work very well. Now we would like to report information about signal strength and error rates. This information is available via the AT protocol (AT+CSQ).

Is there a possibility to connect both the usb_net and the option_uart driver to the different endpoints of the USB device? or should I try to add the required compilation unit (drivers/usb/serial/option.c) to the usb_net driver?

With the recent modernization of the USB API (release 24.05), we take a big step into the direction of sharing an USB device in between separate drivers. Thereby, the resource granularity to split an USB device is on the level of interfaces and not endpoints. Of course, one interface can aggregates up to several endpoints.

So, I do not have the USB configuration of your concrete device at hand, but as long as the serial protocol of the USB device is done in a separate interface from the ethernet one, it should be possible to use distinct drivers.

Now come the “but”: but as we have no concrete scenario tested yet, we haven’t unlocked the possibility to share an USB device within the USB host controller driver fully yet. Especially, we’d like to distinguish drivers with ultimate control from drivers with limited ability to “only” use an interface, but no right to re-configure the USB device. As we do not have tested this thoroughly, it is not recommended yet.

However, it shouldn’t be hard to use it, given that you prevent one of the drivers to re-configure the USB device (probably at best the Genode native driver).
Of course you need to tweak your USB configuration in a way that both drivers have policies to access the device. Finally, you have to remove the checks for double-usage within acquire_device and acquire_single_device within repos/os/src/lib/genode_c_api/usb.cc, like:

--- a/repos/os/src/lib/genode_c_api/usb.cc
+++ b/repos/os/src/lib/genode_c_api/usb.cc
@@ -1382,16 +1382,6 @@ Device_capability Session_component::acquire_device(Device_name const &name)
 
                [&] (genode_usb_device & device) {
                        found = true;
-                       _sessions.apply(
-                               [&] (Session_component &sc) {
-                                       return sc.acquired(device); },
-                               [&] (Session_component &) {
-                                       found = false; });
-
-                       if (!found) {
-                               warning("USB device ", name,
-                                       "already acquired by another session");
-                       }
 
                        cap = _acquire(device.label(), true);
                        _sessions.for_each([&] (Session_component &sc) {
@@ -1415,16 +1405,6 @@ Device_capability Session_component::acquire_single_device()
                        return !cap.valid() && _matches(device); },
                [&] (genode_usb_device & device) {
 
-                       bool acquired = false;
-                       _sessions.apply(
-                               [&] (Session_component &sc) {
-                                       return sc.acquired(device); },
-                               [&] (Session_component &) {
-                                       acquired = true; });
-
-                       if (acquired)
-                               return;
-
                        cap = _acquire(device.label(), true);
                        _sessions.for_each([&] (Session_component &sc) {
                                if (sc._matches(device)) sc.update_devices_rom(); });

I wouldn’t recommend to you to share one USB device in between different Linux driver ports now! There are high chances that the drivers will interfere badly by re-configuring the USB device in initialization simultanously.

If you want to stay on safe, well-worn pathes, of course you can combine usb net & uart Linux ports within one driver component.

Thanks for the information.

I’ll give the connect two drivers a try first, and will give you feedback on how it went. Should I fail on this route, I will update the usb_net driver.

With the patch you provided, both drivers are able to connect to usb_host. Unfortunately whichever connects first wins, the second stops somewhere during the initialization phase.

I will now switch to add the needed parts for the serial interface to usb_net.

Did you used the UART interface with your native driver? If yes, you should simply do not configure the device in that component. As I said using it with two different Linux driver ports won’t work by now for sure.