[PATCH v6 00/15] QRTR Multi-endpoint support

From: Juha-Matti Tilli

Date: Tue Sep 01 2026 - 09:54:59 EST


Hello,

First, I would like to thank Denis Kenzior and Mihai Moldovan for
initially creating this patchset. Without their efforts, there wouldn't
be any progress towards supporting multiple identical ath11k or ath12k
modules on a single Linux host.

As you may know, if you put two identical Qualcomm Atheros ath11k or
ath12k WLAN modules on the same Linux host, they will conflict and
neither works. This is a massive issue in routers, and to solve it, we
need QRTR multi-endpoint support.

I contacted Mihai Moldovan who posted v5 and he said he's been busy and
can't provide an estimate of when he'll post v6. So I picked up his
work, ported it over ath-next and solved the issue of cramming two
32-bit numbers into an unsigned long that can be 32 bits on a 32-bit
architecture. Mihai said he doesn't have any corporate backing and
doesn't care who implements multi-ath11k/ath12k support as long as it
"just works". Since it's been over a year from the previous activity and
since Mihai has been and is busy and said he doesn't care who eventually
implements this, I decided to "steal" the responsibility of posting a v6
to myself since I fortunately have corporate backing. If Mihai so
decides, I'm willing to hand over this patchset back to him.

Some of the patches may need dropping/squashing. For example, "fit node
ID + port number combination into unsigned long" fixes one bug on 32-bit
architectures but introduces another. This needs careful review. I tried
to adjust the behavior to my tastes in "use only low 16 bits of
node/port in 32-bit systems", and this needs careful review, too. Both
of these are candidates for dropping from this patch series.

Furthermore, "validate msglen before ctrl_pkt use", although it seems to
fix a real bug, seems to be orthogonal to this patchset, and could be a
candidate for posting separately.

Also, "limit endpoint range to 16 bits on 32-bit machines", "use nid
modulo 65536 in 32-bit lookups" and "solve the 32-bit unsafe use in
endpoints" are candidates for squashing together. I didn't squash them
yet, since I want to keep my options open at this point, to be able to
easily adapt to any possible code review comments such as squashing or
dropping commits.

Someone could complain that using a "radix tree of radix trees" approach
on 64-bit machines is overkill since a single 64-bit key is enough.
However, this doesn't work on 32-bit machines, and having entirely
different code on 32-bit and 64-bit machines would be a testing
nightmare.

I have tested qrtr with all of these changes, and with Mihai Moldovan's
patches to actually have two identical ath11k or ath12k modules on the
same system. Our limited CPU has issues with ath12k, so I have instead
tested it with two identical ath11k modules. However, Mihai Moldovan
created the ath11k/ath12k patchset in a somewhat non-optimal way,
leaking memory in some use cases, with an O(n) algorithm for looking up
the endpoint id where n is the amount of leaked memory. So I guess I'll
have to rework that entire patchset which should be doable. That's
future work, as none of the leaky O(n) stuff is in this patchset.

But first, before merging the multi-ath11k/ath12k patches, this first
patch set of QRTR multi-endpoint support needs to be merged.

Original description:

The current implementation of QRTR assumes that each entity on the QRTR
IPC bus is uniquely identifiable by its node/port combination, with
node/port combinations being used to route messages between entities.

However, this assumption of uniqueness is problematic in scenarios
where multiple devices with the same node/port combinations are
connected to the system. A practical example is a typical consumer PC
with multiple PCIe-based devices, such as WiFi cards or 5G modems, where
each device could potentially have the same node identifier set. In
such cases, the current QRTR protocol implementation does not provide a
mechanism to differentiate between these devices, making it impossible
to support communication with multiple identical devices.

This patch series addresses this limitation by introducing support for
a concept of an 'endpoint.' Multiple devices with conflicting node/port
combinations can be supported by assigning a unique endpoint identifier
to each one. Such endpoint identifiers can then be used to distinguish
between devices while sending and receiving messages over QRTR sockets.

The patch series maintains backward compatibility with existing clients:
the endpoint concept is added using auxiliary data that can be added to
recvmsg and sendmsg system calls. The QRTR socket interface is extended
as follows:

- Adds QRTR_ENDPOINT auxiliary data element that reports which endpoint
generated a particular message. This auxiliary data is only reported
if the socket was explicitly opted in using setsockopt, enabling the
QRTR_REPORT_ENDPOINT socket option. SOL_QRTR socket level was added
to facilitate this. This requires QRTR clients to be updated to use
recvmsg instead of the more typical recvfrom() or recv() use.

- Similarly, QRTR_ENDPOINT auxiliary data element can be included in
sendmsg() requests. This will allow clients to route QRTR messages
to the desired endpoint, even in cases of node/port conflict between
multiple endpoints.

- Finally, QRTR_BIND_ENDPOINT socket option is introduced. This allows
clients to bind to a particular endpoint (such as a 5G PCIe modem) if
they're only interested in receiving or sending messages to this
device.

NOTE: There is 32-bit unsafe use of radix_tree_insert in this patch set.
This follows the existing usage inside net/qrtr/af_qrtr.c in
qrtr_tx_wait(), qrtr_tx_resume() and qrtr_tx_flow_failed(). This was
done deliberately in order to keep the changes as minimal as possible
until it is known whether the approach outlined is generally acceptable.

v6:
- rebased against current ath-next
- finally solve the 32-bit unsafe use by "radix tree of radix trees"
- remove checks of node/port being in 16-bit range (they may not be)
- Link to v5: https://msgid.link/cover.1754962436.git.ionic@xxxxxxxx

v5:
- fix typos in commit message
- Link to v4: https://msgid.link/cover.1753720934.git.ionic@xxxxxxxx

v4:
- fixed issues found in previous review round:
o lock without unlock
o wrong return value
- Link to v3: https://msgid.link/cover.1753312999.git.ionic@xxxxxxxx

v3:
- rebased against current master
- fix checkpatch.pl warnings
- fix overflow issues with unsigned long radix tree keys by using the
upper half of the storage space for one element and the lower half
of storage for the other element, making sure that the elements fit
into their respective storage space
- Link to v2: https://msgid.link/cover.1752947108.git.ionic@xxxxxxxx

v2:
- rebased against current master
- fixed most issues found in first review round (see individual
commits), minus the 32-bit long unsafe use

v1 link: https://msgid.link/20241018181842.1368394-1-denkenz@xxxxxxxxx

BR, Juha-Matti

Denis Kenzior (10):
net: qrtr: ns: validate msglen before ctrl_pkt use
net: qrtr: allocate and track endpoint ids
net: qrtr: support identical node ids
net: qrtr: Report sender endpoint in aux data
net: qrtr: Report endpoint for locally generated messages
net: qrtr: Allow sendmsg to target an endpoint
net: qrtr: allow socket endpoint binding
net: qrtr: Drop remote {NEW|DEL}_LOOKUP messages
net: qrtr: ns: support multiple endpoints
net: qrtr: mhi: Report endpoint id in sysfs

Juha-Matti Tilli (4):
net: qrtr: use only low 16 bits of node/port in 32-bit systems
net: qrtr: limit endpoint range to 16 bits on 32-bit machines
net: qrtr: use nid modulo 65536 in 32-bit lookups
net: qrtr: solve the 32-bit unsafe use in endpoints

Mihai Moldovan (1):
net: qrtr: fit node ID + port number combination into unsigned long

include/linux/socket.h | 1 +
include/uapi/linux/qrtr.h | 7 +
net/qrtr/af_qrtr.c | 461 ++++++++++++++++++++++++++++++++------
net/qrtr/mhi.c | 14 ++
net/qrtr/ns.c | 316 ++++++++++++++++----------
net/qrtr/qrtr.h | 14 ++
6 files changed, 627 insertions(+), 186 deletions(-)

--
2.34.1