Re: [PATCH net-next v4] wwan dev: Add port for NMEA channel for WWAN devices

From: Sergey Ryazanov
Date: Tue Jan 07 2025 - 18:42:14 EST


Hi Muhammad, Slark,

On 07.01.2025 22:19, Muhammad Nuzaihan wrote:
Hi Everyone, Sorry for the last (HTML) email.

Seemed i forgot Gmail sends HTML email by default and Geary client was broken.

Slark - I've got some vague idea on how it can be implemented with GNSS
according to your helpful last email which helps clear some things.

I should clarify here a bit. Export through GNSS does not mean creating a dedicated PCI driver. It means call the gnss_register_device() function to export the device to the user space as instance of the GNSS class. This should help for ModemManager as well to avoid the NMEA port access. Since the device class will clearly indicate that the NMEA port has nothing common with a cell modem control.

Still, as it was pointed by Loic, it is a good idea to call gnss_register_device() from WWAN core in order to make the WWAN device a common parent of the NMEA port. This should help user space applications as well. A user space application (e.g. GPSd) can easily find a control AT/MBIM/etc port to activate the GNSS functionality of the physical device by checking the NMEA port siblings.

But the patch i'm giving does not work. (NULL deference err,
possibly due to gdev being NULL).

Just sharing on some progress i've made.

A small hint. If a patch is not going to be merged here and now, it's good idea put "RFC" keyword in the subject. E.g.:

[RFC v4] wwan dev: Add port for NMEA channel for WWAN devices

And another small hint. Use the bottom/inline posting style please. It's really hard to read the email conversation backward.

I'm still looking at it and trying to figure out though.

It will be great if you will manage to create the discussed infrastructure inside the WWAN core code. I've already promised Slark to make a prototype, but have a hard time to find a time to do it properly. Sorry :(

On Tue, Jan 7 2025 at 02:05:38 PM +0800, Slark Xiao <slark_xiao@xxxxxxx> wrote:

At 2025-01-07 03:44:35, "Loic Poulain" <loic.poulain@xxxxxxxxxx> wrote:
Hi Muhammad,

+ Slark

On Sun, 5 Jan 2025 at 13:53, Muhammad Nuzaihan <zaihan@xxxxxxxxxxxxxx> wrote:

 Based on the code: drivers/bus/mhi/host/pci_generic.c
 which already has NMEA channel (mhi_quectel_em1xx_channels)
 support in recent kernels but it is never exposed
 as a port.

 This commit exposes that NMEA channel to a port
 to allow tty/gpsd programs to read through
 the /dev/wwan0nmea0 port.

 Tested this change on a new kernel and module
 built and now NMEA (mhi0_NMEA) statements are
 available (attached) through /dev/wwan0nmea0 port on bootup.

 Signed-off-by: Muhammad Nuzaihan Bin Kamal Luddin <zaihan@xxxxxxxxxxxxxx>

This works for sure but I'm not entirely convinced NMEA should be
exposed as a modem control port. In your previous patch version Sergey
pointed to a discussion we had regarding exposing that port as WWAN
child device through the regular GNSS subsystem, which would require
some generic bridge in the WWAN subsystem.

Slark, did you have an opportunity to look at the GNSS solution?

Regards,
Loic

Hi Loic,
This solution same as what I did in last time. We got a wwan0nmea0 device but this
device can't support flow control.
Also, this is not the solution what Sergey expected, I think.
Please refer to the target we talked last time:
/////////////////////
 Basically, components should interact like this:

 Modem PCIe driver <-> WWAN core <-> GNSS core <-> /dev/gnss0

 We need the GNSS core to export the modem NMEA port as instance of
 'gnss' class.

 We need WWAN core between the modem driver and the GSNN core because we
 need a common parent for GNSS port and modem control port (e.g. AT,
 MBIM). Since we are already exporting control ports via the WWAN
 subsystem, the GNSS port should also be exported through the WWAN
 subsystem. To keep devices hierarchy like this:

                        .--> AT port
 PCIe dev -> WWAN dev -|
                        '--> GNSS port

 Back to the implementation. Probably we should introduce a new port
 type, e.g. WWAN_PORT_NMEA. And this port type should have a special
 handling in the WWAN core.

 Similar like what I did in my local. I named it as WWAN_PORT_GNSS and
 put it as same level with AT port.

 wwan_create_port() function should not directly create a char device.
 Instead, it should call gnss_allocate_device() and
 gnss_register_device() to register the port with GNSS subsystem.