net: qrtr: Add support for using identical MHI endpoint devices
Subsystems (6)
v4 cover net: qrtr: Add support for using identical MHI endpoint devices
Hi,
This series reworks the QRTR driver to add support for using identical MHI endpoint devices at the same time. Currently, QRTR driver has a limitation on using more than one identical MHI endpoint devices like QCS6490 or any Qcom Endpoint device making use of QRTR at the same time. Because of the fact that these devices will have the identical QRTR node id, they cannot be used at the same time, on the same host machine.
This limitation is a blocker for running upstream kernel on devices like Qcom based routers as they often have multiple identical WLAN Endpoint devices connected to the Router SoC.
This series supersedes the following 2 series from Juha:
https://lore.kernel.org/all/[email protected]
https://lore.kernel.org/all/[email protected]
Compared to the series from Juha, this series simplifies the multi-endpoint support by computing a unique node id for each MHI endpoint and uses it for the internal QRTR book keeping. This ensures that even if the MHI endpoint devices have same node ids, the host QRTR will always use a unique node id for each one of them.
More details can be found in the individual patches.
Merge Strategy
==============
Since both QRTR and ath drivers are falling under the networking tree, the whole series can be merged through netdev tree.
---
Changes in v4:
- Moved the 'ep_nid' and the node id assignment into a single
'qrtr_nodes_lock' critical section and used READ_ONCE() elsewhere
- Propagated the radix tree insert error out of qrtr_node_assign() and
rejected the packet or failed the endpoint registration
- Fixed the assign condition that stopped adding bridged node ids as
lookup keys
- Moved the control packet length check to qrtr_endpoint_post() and
extended it to DEL_SERVER and DEL_CLIENT
- Rejected endpoint node ids at and above QRTR_NODE_HOST_BASE
- Returned error for the QMI message received from an unknown server in ath{11k,12k} so that the QMI core drops the service
- Dropped Juha's Tested-by and Vasanth's Reviewed-bt as the code changed since v3
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Added missing qrtr_node_rewrite_ctrl() for QRTR_TYPE_RESUME_TX
- Fixed the types of ath{11k/12k}_pci_get_qrtr_node_id() and helpers to use 'unsigned int' to match qrtr_host_node_id()
- Collected tags
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Rebased on top of net-next/main
- Used READ/WRITE_ONCE for reading/writing ep_nid
- Link to v1: https://patch.msgid.link/[email protected]
---
Manivannan Sadhasivam (4):
net: qrtr: Allow the host QRTR to assign a unique node id
net: qrtr: Assign unique node id for MHI endpoints
wifi: ath11k: Connect to the QMI server belonging to the device owned by this driver
wifi: ath12k: Connect to the QMI server belonging to the device owned by this driver
MAINTAINERS | 1 + drivers/net/wireless/ath/ath11k/hif.h | 9 +++ drivers/net/wireless/ath/ath11k/pci.c | 9 +++ drivers/net/wireless/ath/ath11k/qmi.c | 10 +++ drivers/net/wireless/ath/ath12k/hif.h | 9 +++ drivers/net/wireless/ath/ath12k/pci.c | 9 +++ drivers/net/wireless/ath/ath12k/qmi.c | 11 +++ include/net/qrtr.h | 22 ++++++ net/qrtr/af_qrtr.c | 141 ++++++++++++++++++++++++++++++---- net/qrtr/mhi.c | 4 +- 10 files changed, 208 insertions(+), 17 deletions(-)
---
base-commit: 8830e65ed46de41f849eefb8ba227d4852c460f6
change-id: 20260918-qrtr-multi-ep-c27c2bc54ee1
Best regards,
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH v4 1/4 net: qrtr: Allow the host QRTR to assign a unique node id
Currently, QRTR identifies each remote node by the value of the 'src_node_id' field in the received packet and uses the node id as the key to store the node to the internal 'qrtr_nodes' radix tree.
But this approach comes with a limitation. When more than one remote node share the same id, then QRTR can only add the first node to the radix tree and has to drop the successive nodes with the same node id as the 'key' in radix tree has to be unique. This prevents connecting identical Qcom PCIe WLAN devices to a single host at the same time.
To fix this limitation, allow the host QRTR to use the node id (nid) received from the endpoint driver during qrtr_endpoint_register() as the unique node id and use it as the 'key' for the internal radix tree. Also, store the received 'src_id' in a new 'qrtr_node->ep_nid' field and replace the 'ep_nid' with the unique 'nid' in the QRTR control packets if both differ i.e., an endpoint driver has passed a unique 'nid' during qrtr_endpoint_register(). To maintain symmetry, replace the 'nid' with the 'ep_nid' while sending the packet back to the remote node if both differ.
A node can also bridge other distant nodes, so the source id of an incoming packet is not always the id the endpoint advertises for itself. Keep adding such ids to the radix tree as additional keys for the same node, as it was done before this change. Otherwise the bridged nodes would lose their route and qrtr_sendmsg() would start failing with -ECONNRESET for them.
Currently, all QRTR endpoint drivers pass 'QRTR_EP_NID_AUTO' as the 'nid' during qrtr_endpoint_register(). So 'ep_nid' and 'nid' are same and the routing behavior is not changed.
Finally, since qrtr_node_rewrite_ctrl() dereferences the control packet for DEL_SERVER and DEL_CLIENT as well, extend the existing length check in qrtr_endpoint_post() to cover both types.
--- net/qrtr/af_qrtr.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 116 insertions(+), 16 deletions(-)
net/qrtr/af_qrtr.c +116 -16
@@ -118,7 +118,8 @@ static DEFINE_XARRAY_ALLOC(qrtr_ports);* @ep_lock: lock for endpoint management and callbacks * @ep: endpoint * @ref: reference count for node -* @nid: node id +* @nid: node id assigned by the host QRTR +* @ep_nid: endpoint's own node id as received * @qrtr_tx_flow: xarray of qrtr_tx_flow, keyed by node << 32 | port * @qrtr_tx_lock: lock for qrtr_tx_flow inserts * @hello_sent: hello packet send successful
@@ -131,6 +132,7 @@ struct qrtr_node {struct qrtr_endpoint *ep;struct kref ref;unsigned int nid; +unsigned int ep_nid;struct xarray qrtr_tx_flow;struct mutex qrtr_tx_lock;/* for qrtr_tx_flow */
@@ -347,6 +349,7 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, {struct qrtr_hdr_v1 *hdr;size_t len = skb->len; +unsigned int dst_node;int rc, confirm_rx;mutex_lock (&node->ep_lock);
@@ -369,10 +372,14 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, hdr->src_node_id =cpu_to_le32 (from->sq_node); hdr->src_port_id =cpu_to_le32 (from->sq_port);if (to->sq_port ==QRTR_PORT_CTRL ) { - hdr->dst_node_id =cpu_to_le32 (READ_ONCE (node->nid)); + hdr->dst_node_id =cpu_to_le32 (READ_ONCE (node->ep_nid)); hdr->dst_port_id =cpu_to_le32 (QRTR_PORT_CTRL ); }else { - hdr->dst_node_id =cpu_to_le32 (to->sq_node); +/* Put back the endpoint's own node id */ + dst_node = to->sq_node; +if (dst_node ==READ_ONCE (node->nid)) + dst_node =READ_ONCE (node->ep_nid); + hdr->dst_node_id =cpu_to_le32 (dst_node); hdr->dst_port_id =cpu_to_le32 (to->sq_port); }
@@ -422,23 +429,72 @@ static struct qrtr_node *qrtr_node_lookup(unsigned int nid)return node; } -/* Assign node id to node. +/* Add 'nid' as a lookup key for 'node', and adopt it as the node's own id if +* the node does not have one yet. +* +* Callers must hold 'qrtr_nodes_lock'. * -* This is mostly useful for automatic node id assignment, based on -* the source id in the incoming packet. +* Return: 0 on success; negative error code on failure */ -static void qrtr_node_assign (struct qrtr_node *node,unsigned int nid) +static int __qrtr_node_assign (struct qrtr_node *node,unsigned int nid) { -unsigned long flags; +int rc;if (nid ==QRTR_EP_NID_AUTO ) -return ; +return 0 ; + +if (radix_tree_lookup (&qrtr_nodes, nid) == node) +return 0 ; + + rc =radix_tree_insert (&qrtr_nodes, nid, node); +if (rc) +return rc; -spin_lock_irqsave (&qrtr_nodes_lock, flags); -radix_tree_insert (&qrtr_nodes, nid, node);if (node->nid ==QRTR_EP_NID_AUTO )WRITE_ONCE (node->nid, nid); + +return 0 ; +} + +/* Assign node id to node. +* +* Return: 0 on success; negative error code on failure +*/ +static int qrtr_node_assign (struct qrtr_node *node,unsigned int nid) +{ +unsigned long flags; +int rc; + +spin_lock_irqsave (&qrtr_nodes_lock, flags); + rc =__qrtr_node_assign (node, nid);spin_unlock_irqrestore (&qrtr_nodes_lock, flags); + +return rc; +} + +/* Replace the node id in the control packet with 'node->nid', if both are +* different. +*/ +static void qrtr_node_rewrite_ctrl (struct qrtr_node *node,unsigned int type, +struct sk_buff *skb) +{ +unsigned int ep_nid =READ_ONCE (node->ep_nid); +unsigned int host_nid =READ_ONCE (node->nid); +struct qrtr_ctrl_pkt *pkt; +__le32 *nid; + +if (host_nid == ep_nid) +return ; + + pkt = (struct qrtr_ctrl_pkt *)skb->data; +if (type ==QRTR_TYPE_DEL_CLIENT || type ==QRTR_TYPE_RESUME_TX ) + nid = &pkt->client.node; +else + nid = &pkt->server.node; + +/* Rewrite only the endpoint's node id, not those of bridged nodes */ +if (le32_to_cpu (*nid) == ep_nid) + *nid =cpu_to_le32 (host_nid); }/**
@@ -457,9 +513,12 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)struct qrtr_sock *ipc;struct sk_buff *skb;struct qrtr_cb *cb; +unsigned long flags;size_t size;unsigned int ver; +unsigned int nid;size_t hdrlen; +int rc =0 ;if (len ==0 || len &3 )return -EINVAL ;
@@ -521,6 +580,8 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) goto err;if ((cb->type ==QRTR_TYPE_NEW_SERVER || + cb->type ==QRTR_TYPE_DEL_SERVER || + cb->type ==QRTR_TYPE_DEL_CLIENT || cb->type ==QRTR_TYPE_RESUME_TX ) && size <sizeof (struct qrtr_ctrl_pkt )) goto err;
@@ -531,16 +592,46 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)skb_put_data (skb, data + hdrlen, size); -qrtr_node_assign (node, cb->src_node); + nid = cb->src_node; + +spin_lock_irqsave (&qrtr_nodes_lock, flags); + +if (node->ep_nid ==QRTR_EP_NID_AUTO ) +WRITE_ONCE (node->ep_nid, nid); + +/* Add the source id to the lookup table only if 'node->nid' is auto +* assigned or the packet came from a bridged node. +*/ +if (node->nid ==QRTR_EP_NID_AUTO || nid != node->ep_nid) + rc =__qrtr_node_assign (node, nid); + +spin_unlock_irqrestore (&qrtr_nodes_lock, flags); + +if (rc) + goto err_nid;if (cb->type ==QRTR_TYPE_NEW_SERVER ) {/* Remote node endpoint can bridge other distant nodes */ -const struct qrtr_ctrl_pkt *pkt; +const struct qrtr_ctrl_pkt *pkt = data + hdrlen; + + nid =le32_to_cpu (pkt->server.node); - pkt = data + hdrlen; -qrtr_node_assign (node,le32_to_cpu (pkt->server.node)); +if (nid !=READ_ONCE (node->ep_nid)) { + rc =qrtr_node_assign (node, nid); +if (rc) + goto err_nid; + } } +if (cb->src_node ==READ_ONCE (node->ep_nid)) + cb->src_node =READ_ONCE (node->nid); + +if (cb->type ==QRTR_TYPE_NEW_SERVER || + cb->type ==QRTR_TYPE_DEL_SERVER || + cb->type ==QRTR_TYPE_DEL_CLIENT || + cb->type ==QRTR_TYPE_RESUME_TX ) +qrtr_node_rewrite_ctrl (node, cb->type, skb); +if (cb->type ==QRTR_TYPE_RESUME_TX ) {qrtr_tx_resume (node, skb); }else {
@@ -558,6 +649,8 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)return 0 ; +err_nid: +pr_err_ratelimited ("qrtr: cannot route node id %u: %d\n" , nid, rc); err:kfree_skb (skb);return -EINVAL ;
@@ -634,6 +727,7 @@ static void qrtr_hello_work(struct work_struct *work)int qrtr_endpoint_register (struct qrtr_endpoint *ep,unsigned int nid) {struct qrtr_node *node; +int rc;if (!ep || !ep->xmit)return -EINVAL ;
@@ -646,6 +740,7 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid)mutex_init (&node->ep_lock);skb_queue_head_init (&node->rx_queue); node->nid =QRTR_EP_NID_AUTO ; + node->ep_nid =QRTR_EP_NID_AUTO ; node->ep = ep; node->hello_sent = false;
@@ -654,7 +749,12 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid)xa_init (&node->qrtr_tx_flow);mutex_init (&node->qrtr_tx_lock); -qrtr_node_assign (node, nid); + rc =qrtr_node_assign (node, nid); +if (rc) { +pr_err ("qrtr: cannot assign node id %u: %d\n" , nid, rc); +kfree (node); +return rc; + }mutex_lock (&qrtr_node_lock);list_add (&node->item, &qrtr_all_nodes);
Signature · 1 line
2.43.0
Re: [PATCH v4 1/4] net: qrtr: Allow the host QRTR to assign a unique node id
Quoted 30 lines · Manivannan Sadhasivam
Currently, QRTR identifies each remote node by the value of the '
src_node_id' field in the received packet and uses the node id as the key to store the node to the internal 'qrtr_nodes' radix tree.But this approach comes with a limitation. When more than one remote node share the same id, then QRTR can only add the first node to the radix tree and has to drop the successive nodes with the same node id as the 'key' in radix tree has to be unique. This prevents connecting identical Qcom PCIe WLAN devices to a single host at the same time.
To fix this limitation, allow the host QRTR to use the node id (nid) received from the endpoint driver during
qrtr_endpoint_register()as the unique node id and use it as the 'key' for the internal radix tree. Also, store the received 'src_id' in a new 'qrtr_node->ep_nid' field and replace the 'ep_nid' with the unique 'nid' in the QRTR control packets if both differ i.e., an endpoint driver has passed a unique 'nid' duringqrtr_endpoint_register(). To maintain symmetry, replace the 'nid' with the 'ep_nid' while sending the packet back to the remote node if both differ.A node can also bridge other distant nodes, so the source id of an incoming packet is not always the id the endpoint advertises for itself. Keep adding such ids to the radix tree as additional keys for the same node, as it was done before this change. Otherwise the bridged nodes would lose their route and
qrtr_sendmsg()would start failing with-ECONNRESETfor them.Currently, all QRTR endpoint drivers pass '
QRTR_EP_NID_AUTO' as the 'nid' duringqrtr_endpoint_register(). So 'ep_nid' and 'nid' are same and the routing behavior is not changed.
Quoted 7 lines
Finally, since
qrtr_node_rewrite_ctrl()dereferences the control packet forDEL_SERVERandDEL_CLIENTas well, extend the existing length check inqrtr_endpoint_post()to cover both types.Signed-off-by Manivannan Sadhasivam <[email protected]>--- net/qrtr/af_qrtr.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++-------
PATCH v4 2/4 net: qrtr: Assign unique node id for MHI endpoints
In reply to Manivannan SadhasivamNow that the QRTR driver allows using the unique node id for each device, which is different from the node id received from the remote node, compute a unique node id using a new API, qrtr_host_node_id().
This API takes the 'index' parameter and adds it to QRTR_NODE_HOST_BASE. The base is chosen well above the node ids in use by the remote nodes, so that the host assigned ids never collide with the pre-existing ones.
Since the ids at and above the base now belong to the host, reject any packet carrying one as the source node id or as the node id of an announced server in qrtr_endpoint_post().
Finally, call the new API from MHI endpoint driver by passing the MHI controller index as the parameter. The MHI controller index is unique for each controller, thereby for each MHI endpoint device.
--- MAINTAINERS | 1 + include/net/qrtr.h | 22 ++++++++++++++++++++++ net/qrtr/af_qrtr.c | 9 +++++++++ net/qrtr/mhi.c | 4 +++- 4 files changed, 35 insertions(+), 1 deletion(-)
MAINTAINERS +1 -0
@@ -22511,6 +22511,7 @@ QUALCOMM IPC ROUTER (QRTR) DRIVER M: Manivannan Sadhasivam <[email protected]> L: [email protected] S: Maintained +F: include/net/qrtr.h F: include/trace/events/qrtr.h F: include/uapi/linux/qrtr.h F: net/qrtr/
include/net/qrtr.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _NET_QRTR_H +#define _NET_QRTR_H + +#include <linux/types.h> + +/* Node ids at and above this base are reserved for the host and are never +* accepted from an endpoint. The base is well above the ids used by the +* remote nodes, so that pre-existing node ids stay untouched. +*/ +#define QRTR_NODE_HOST_BASE 0x10000u + +/* Compute host node id from a per-device index. The index must be unique +* among the host assigned endpoints and smaller than QRTR_NODE_HOST_BASE. +*/ +static inline unsigned int qrtr_host_node_id (unsigned int index) +{ +return QRTR_NODE_HOST_BASE + index; +} + +#endif /* _NET_QRTR_H */
net/qrtr/af_qrtr.c +9 -0
@@ -11,6 +11,7 @@#include <linux/wait.h> #include <linux/workqueue.h> +#include <net/qrtr.h> #include <net/sock.h> #include "qrtr.h"
@@ -590,6 +591,12 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) cb->type != QRTR_TYPE_RESUME_TX) goto err; +/* Host assigned node ids are not supposed to overlap with +* remote node ids +*/ +if (cb->src_node >=QRTR_NODE_HOST_BASE ) + goto err; +skb_put_data (skb, data + hdrlen, size); nid = cb->src_node;
@@ -615,6 +622,8 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)const struct qrtr_ctrl_pkt *pkt = data + hdrlen; nid =le32_to_cpu (pkt->server.node); +if (nid >=QRTR_NODE_HOST_BASE ) + goto err;if (nid !=READ_ONCE (node->ep_nid)) { rc =qrtr_node_assign (node, nid);
net/qrtr/mhi.c +3 -1
@@ -6,6 +6,7 @@#include <linux/mhi.h> #include <linux/module.h> #include <linux/skbuff.h> +#include <net/qrtr.h> #include <net/sock.h> #include "qrtr.h"
@@ -127,7 +128,8 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev,if (rc)return rc; - rc =qrtr_endpoint_register (&qdev->ep,QRTR_EP_NID_AUTO ); + rc =qrtr_endpoint_register (&qdev->ep, +qrtr_host_node_id (mhi_dev->mhi_cntrl->index));if (rc) goto err_unprepare;
Signature · 1 line
2.43.0
Re: [PATCH v4 2/4] net: qrtr: Assign unique node id for MHI endpoints
Quoted 16 lines · Manivannan Sadhasivam
Now that the QRTR driver allows using the unique node id for each device, which is different from the node id received from the remote node, compute a unique node id using a new API,
qrtr_host_node_id().This API takes the 'index' parameter and adds it to
QRTR_NODE_HOST_BASE. The base is chosen well above the node ids in use by the remote nodes, so that the host assigned ids never collide with the pre-existing ones.Since the ids at and above the base now belong to the host, reject any packet carrying one as the source node id or as the node id of an announced server in
qrtr_endpoint_post().Finally, call the new API from MHI endpoint driver by passing the MHI controller index as the parameter. The MHI controller index is unique for each controller, thereby for each MHI endpoint device.
Quoted 7 lines
Signed-off-by Manivannan Sadhasivam <[email protected]>--- MAINTAINERS | 1 + include/net/qrtr.h | 22 ++++++++++++++++++++++ net/qrtr/af_qrtr.c | 9 +++++++++ net/qrtr/mhi.c | 4 +++- 4 files changed, 35 insertions(+), 1 deletion(-)
PATCH v4 3/4 wifi: ath11k: Connect to the QMI server belonging to the device owned by this driver
In reply to Manivannan SadhasivamWhen two identical ath11k PCIe devices are connected to the same host, both advertise the WLFW service with the same service and instance id. The QMI lookup reports both servers to each device, so a device may connect to the firmware running on the other device.
But now, QRTR provides each MHI endpoint a unique node id which is different from the node id announced by the device. So use the same id to pick the correct server. Add a get_qrtr_node_id() HIF callback that returns the node id derived from the MHI controller index and zero for transports that do not assign one. In the new_server callback, reject any service whose node id does not match. A node id of zero disables the check, so transports that do not assign one keep their current behavior.
--- drivers/net/wireless/ath/ath11k/hif.h | 9 +++++++++ drivers/net/wireless/ath/ath11k/pci.c | 9 +++++++++ drivers/net/wireless/ath/ath11k/qmi.c | 10 ++++++++++ 3 files changed, 28 insertions(+)
drivers/net/wireless/ath/ath11k/hif.h +9 -0
@@ -32,6 +32,7 @@ struct ath11k_hif_ops {void (*ce_irq_disable)(struct ath11k_base *ab);void (*get_ce_msi_idx)(struct ath11k_base *ab,u32 ce_id,u32 *msi_idx);void (*coredump_download)(struct ath11k_base *ab); +unsigned int (*get_qrtr_node_id)(struct ath11k_base *ab); };static inline void ath11k_hif_ce_irq_enable (struct ath11k_base *ab)
@@ -159,4 +160,12 @@ static inline void ath11k_hif_coredump_download(struct ath11k_base *ab) ab->hif.ops->coredump_download(ab); } +static inline unsigned int ath11k_hif_get_qrtr_node_id (struct ath11k_base *ab) +{ +if (!ab->hif.ops->get_qrtr_node_id) +return 0 ; + +return ab->hif.ops->get_qrtr_node_id (ab); +} +#endif /* _HIF_H_ */
drivers/net/wireless/ath/ath11k/pci.c +9 -0
@@ -10,6 +10,7 @@#include <linux/of.h> #include <linux/time.h> #include <linux/vmalloc.h> +#include <net/qrtr.h> #include "pci.h" #include "core.h"
@@ -900,6 +901,13 @@ static int ath11k_pci_start(struct ath11k_base *ab)return 0 ; } +static unsigned int ath11k_pci_get_qrtr_node_id (struct ath11k_base *ab) +{ +struct ath11k_pci *ab_pci =ath11k_pci_priv (ab); + +return qrtr_host_node_id (ab_pci->mhi_ctrl->index); +} +static const struct ath11k_hif_ops ath11k_pci_hif_ops = { .start = ath11k_pci_start, .stop = ath11k_pcic_stop,
@@ -921,6 +929,7 @@ static const struct ath11k_hif_ops ath11k_pci_hif_ops = {#ifdef CONFIG_DEV_COREDUMP .coredump_download = ath11k_pci_coredump_download, #endif + .get_qrtr_node_id = ath11k_pci_get_qrtr_node_id, };static void ath11k_pci_read_hw_version (struct ath11k_base *ab,u32 *major,u32 *minor)
drivers/net/wireless/ath/ath11k/qmi.c +10 -0
@@ -3170,8 +3170,18 @@ static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);struct ath11k_base *ab = qmi->ab;struct sockaddr_qrtr *sq = &qmi->sq; +unsigned int node_id;int ret; +/* Identical devices advertise the same QMI services, so connect only to +* the QMI server on this device's node. A node id of 0 means the +* transport has not assigned a unique node id, so accept the server +* unfiltered. +*/ + node_id =ath11k_hif_get_qrtr_node_id (ab); +if (node_id && service->node != node_id) +return -EINVAL ; + sq->sq_family =AF_QIPCRTR ; sq->sq_node = service->node; sq->sq_port = service->port;
Signature · 1 line
2.43.0
Re: [PATCH v4 3/4] wifi: ath11k: Connect to the QMI server belonging to the device owned by this driver
Quoted 13 lines · Manivannan Sadhasivam
When two identical ath11k PCIe devices are connected to the same host, both advertise the WLFW service with the same service and instance id. The QMI lookup reports both servers to each device, so a device may connect to the firmware running on the other device.
But now, QRTR provides each MHI endpoint a unique node id which is different from the node id announced by the device. So use the same id to pick the correct server. Add a
get_qrtr_node_id()HIF callback that returns the node id derived from the MHI controller index and zero for transports that do not assign one. In thenew_servercallback, reject any service whose node id does not match. A node id of zero disables the check, so transports that do not assign one keep their current behavior.
Quoted 1 line
Signed-off-by Manivannan Sadhasivam <[email protected]>
Re: [PATCH v4 3/4] wifi: ath11k: Connect to the QMI server belonging to the device owned by this driver
In reply to Manivannan Sadhasivamdrivers/net/wireless/ath/ath11k/qmi.c static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, · line 3176
Quoted 12 lines · On 10/22/2026 10:43 AM, Manivannan Sadhasivam via B4 Relay wrote:
drivers/net/wireless/ath/ath11k/qmi.c +2
-0@@ -3170,8 +3170,18 @@ static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);struct ath11k_base *ab = qmi->ab;struct sockaddr_qrtr *sq = &qmi->sq; +unsigned int node_id;int ret; +/* Identical devices advertise the same QMI services, so connect only to
nit: note that networking code no longer uses this block comment style, so it is preferred to have /* on a line by itself
drivers/net/wireless/ath/ath11k/qmi.c static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, · line 3187
Quoted 12 lines
drivers/net/wireless/ath/ath11k/qmi.c +8
-0+* the QMI server on this device's node. A node id of 0 means the +* transport has not assigned a unique node id, so accept the server +* unfiltered. +*/ + node_id =ath11k_hif_get_qrtr_node_id (ab); +if (node_id && service->node != node_id) +return -EINVAL ; + sq->sq_family =AF_QIPCRTR ; sq->sq_node = service->node; sq->sq_port = service->port;
Since the requested merge strategy is for netdev to take the entire series:
PATCH v4 4/4 wifi: ath12k: Connect to the QMI server belonging to the device owned by this driver
In reply to Manivannan SadhasivamWhen two identical ath12k PCIe devices are connected to the same host, both advertise the WLFW service with the same service and instance id. The QMI lookup reports both servers to each device, so a device may connect to the firmware running on the other device.
But now, QRTR provides each MHI endpoint a unique node id which is different from the node id announced by the device. So use the same id to pick the correct server. Add a get_qrtr_node_id() HIF callback that returns the node id derived from the MHI controller index and zero for transports that do not assign one. In the new_server callback, reject any service whose node id does not match. A node id of zero disables the check, so transports that do not assign one keep their current behavior.
--- drivers/net/wireless/ath/ath12k/hif.h | 9 +++++++++ drivers/net/wireless/ath/ath12k/pci.c | 9 +++++++++ drivers/net/wireless/ath/ath12k/qmi.c | 11 +++++++++++ 3 files changed, 29 insertions(+)
drivers/net/wireless/ath/ath12k/hif.h +9 -0
@@ -32,6 +32,7 @@ struct ath12k_hif_ops {void (*get_ce_msi_idx)(struct ath12k_base *ab,u32 ce_id,u32 *msi_idx);int (*panic_handler)(struct ath12k_base *ab);void (*coredump_download)(struct ath12k_base *ab); +unsigned int (*get_qrtr_node_id)(struct ath12k_base *ab); }; static inline int ath12k_hif_map_service_to_pipe(struct ath12k_base *ab, u16 service_id,
@@ -162,4 +163,12 @@ static inline void ath12k_hif_coredump_download(struct ath12k_base *ab)if (ab->hif.ops->coredump_download) ab->hif.ops->coredump_download(ab); } + +static inline unsigned int ath12k_hif_get_qrtr_node_id (struct ath12k_base *ab) +{ +if (!ab->hif.ops->get_qrtr_node_id) +return 0 ; + +return ab->hif.ops->get_qrtr_node_id (ab); +}#endif /* ATH12K_HIF_H */
drivers/net/wireless/ath/ath12k/pci.c +9 -0
@@ -10,6 +10,7 @@#include <linux/pci.h> #include <linux/time.h> #include <linux/vmalloc.h> +#include <net/qrtr.h> #include "pci.h" #include "core.h"
@@ -1491,6 +1492,13 @@ static int ath12k_pci_panic_handler(struct ath12k_base *ab)return NOTIFY_OK ; } +static unsigned int ath12k_pci_get_qrtr_node_id (struct ath12k_base *ab) +{ +struct ath12k_pci *ab_pci =ath12k_pci_priv (ab); + +return qrtr_host_node_id (ab_pci->mhi_ctrl->index); +} +static const struct ath12k_hif_ops ath12k_pci_hif_ops = { .start = ath12k_pci_start, .stop = ath12k_pci_stop,
@@ -1512,6 +1520,7 @@ static const struct ath12k_hif_ops ath12k_pci_hif_ops = {#ifdef CONFIG_ATH12K_COREDUMP .coredump_download = ath12k_pci_coredump_download, #endif + .get_qrtr_node_id = ath12k_pci_get_qrtr_node_id, }; static enum ath12k_device_family
drivers/net/wireless/ath/ath12k/qmi.c +11 -0
@@ -9,6 +9,7 @@#include "qmi.h" #include "core.h" #include "debug.h" +#include "hif.h" #include <linux/of.h> #include <linux/firmware.h> #include <linux/of_address.h>
@@ -3940,8 +3941,18 @@ static int ath12k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, struct ath12k_qmi *qmi = container_of(qmi_hdl, struct ath12k_qmi, handle);struct ath12k_base *ab = qmi->ab;struct sockaddr_qrtr *sq = &qmi->sq; +unsigned int node_id;int ret; +/* Identical devices advertise the same QMI services, so connect only to +* the QMI server on this device's node. A node id of 0 means the +* transport has not assigned a unique node id, so accept the server +* unfiltered. +*/ + node_id =ath12k_hif_get_qrtr_node_id (ab); +if (node_id && service->node != node_id) +return -EINVAL ; + sq->sq_family =AF_QIPCRTR ; sq->sq_node = service->node; sq->sq_port = service->port;
Signature · 1 line
2.43.0
Re: [PATCH v4 4/4] wifi: ath12k: Connect to the QMI server belonging to the device owned by this driver
Quoted 7 lines · On Thu, Oct 22, 2026, at 20:43, Manivannan Sadhasivam via B4 Relay wrote:
From: Manivannan Sadhasivam <[email protected]>
When two identical ath12k PCIe devices are connected to the same host, both advertise the WLFW service with the same service and instance id. The QMI lookup reports both servers to each device, so a device may connect to the firmware running on the other device.
Quoted 7 lines
But now, QRTR provides each MHI endpoint a unique node id which is different from the node id announced by the device. So use the same id to pick the correct server. Add a
get_qrtr_node_id()HIF callback that returns the node id derived from the MHI controller index and zero for transports that do not assign one. In thenew_servercallback, reject any service whose node id does not match. A node id of zero disables the check, so transports that do not assign one keep their current behavior.
Tested-on: 2x WCN7850 hw2.0 WLAN.IOE_HMT.1.1-00018-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1
As always, I took the entire state of the QRTR directory as of after these changes, on top of 6.18.53 kernel, and with some trivial changes like kzalloc_obj made it compile. Then I cherry-picked the ath11k/ath12k changes, which had no conflicts now.
I have two ath12k access points on this router, both work simultaneously.
If somebody wants to test this backported variant, it's here:
https://github.com/jmtilli/linux/tree/6_18_multi_ath11k_ath12k_mani_v4
BR, Juha-Matti
Re: [PATCH v4 4/4] wifi: ath12k: Connect to the QMI server belonging to the MHI endpoint that received the packet
In reply to Manivannan SadhasivamTested-on: QCC2072 hw1.0 PCI WLAN.COL.1.0.c2-00277-QCACOLSWPL_V1_TO_SILICONZ-1
I took the entire state of the QRTR directory as of after these changes, on top of 6.18.44 kernel, and with some trivial changes to avoid conflicts. Then I cherry-picked the ath11k/ath12k changes, which
had no conflicts.
Before these changes, Cologne WLAN QRTR NID could conflict with CDSP QRTR NID. After applying this series, the conflict is gone and WLAN/CDSP QRTR services work as expected.
Re: [PATCH v4 4/4] wifi: ath12k: Connect to the QMI server belonging to the device owned by this driver
In reply to Manivannan SadhasivamQuoted 13 lines · Manivannan Sadhasivam
When two identical ath12k PCIe devices are connected to the same host, both advertise the WLFW service with the same service and instance id. The QMI lookup reports both servers to each device, so a device may connect to the firmware running on the other device.
But now, QRTR provides each MHI endpoint a unique node id which is different from the node id announced by the device. So use the same id to pick the correct server. Add a
get_qrtr_node_id()HIF callback that returns the node id derived from the MHI controller index and zero for transports that do not assign one. In thenew_servercallback, reject any service whose node id does not match. A node id of zero disables the check, so transports that do not assign one keep their current behavior.
Quoted 1 line
Signed-off-by Manivannan Sadhasivam <[email protected]>
Re: [PATCH v4 4/4] wifi: ath12k: Connect to the QMI server belonging to the device owned by this driver
In reply to Manivannan SadhasivamQuoted 13 lines · On 10/22/2026 10:43 AM, Manivannan Sadhasivam via B4 Relay wrote:
drivers/net/wireless/ath/ath12k/pci.c +1
-0@@ -10,6 +10,7 @@#include <linux/pci.h> #include <linux/time.h> #include <linux/vmalloc.h> +#include <net/qrtr.h> #include "pci.h" #include "core.h"
drivers/net/wireless/ath/ath12k/pci.c static int ath12k_pci_panic_handler(struct ath12k_base *ab) · line 1501
Quoted 10 lines
drivers/net/wireless/ath/ath12k/pci.c +7
-0@@ -1491,6 +1492,13 @@ static int ath12k_pci_panic_handler(struct ath12k_base *ab)return NOTIFY_OK ; } +static unsigned int ath12k_pci_get_qrtr_node_id (struct ath12k_base *ab) +{ +struct ath12k_pci *ab_pci =ath12k_pci_priv (ab); + +return qrtr_host_node_id (ab_pci->mhi_ctrl->index); +} +
note this hunk has a trivial conflict with current ath12k that landed during the merge window since the ath12k_pci_panic_handler() that is part of the context has been removed
Quoted 3 lines
drivers/net/wireless/ath/ath12k/pci.c +0
-0static const struct ath12k_hif_ops ath12k_pci_hif_ops = { .start = ath12k_pci_start, .stop = ath12k_pci_stop,
...
Quoted 13 lines
drivers/net/wireless/ath/ath12k/qmi.c +1
-0@@ -9,6 +9,7 @@#include "qmi.h" #include "core.h" #include "debug.h" +#include "hif.h" #include <linux/of.h> #include <linux/firmware.h> #include <linux/of_address.h>
drivers/net/wireless/ath/ath12k/qmi.c static int ath12k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, · line 3947
Quoted 7 lines
drivers/net/wireless/ath/ath12k/qmi.c +2
-0@@ -3940,8 +3941,18 @@ static int ath12k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, struct ath12k_qmi *qmi = container_of(qmi_hdl, struct ath12k_qmi, handle);struct ath12k_base *ab = qmi->ab;struct sockaddr_qrtr *sq = &qmi->sq; +unsigned int node_id;int ret; +/* Identical devices advertise the same QMI services, so connect only to
note that networking code no longer uses this block comment style, so it is preferred to have /* on a line by itself
drivers/net/wireless/ath/ath12k/qmi.c static int ath12k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, · line 3958
Quoted 12 lines
drivers/net/wireless/ath/ath12k/qmi.c +8
-0+* the QMI server on this device's node. A node id of 0 means the +* transport has not assigned a unique node id, so accept the server +* unfiltered. +*/ + node_id =ath12k_hif_get_qrtr_node_id (ab); +if (node_id && service->node != node_id) +return -EINVAL ; + sq->sq_family =AF_QIPCRTR ; sq->sq_node = service->node; sq->sq_port = service->port;
Since the requested merge strategy is for netdev to take the entire series:
Jakub Kicinski
maintainerQuoted 5 lines · On Thu, 22 Oct 2026 19:43:06 +0200 Manivannan Sadhasivam via B4 Relay wrote:
Merge Strategy
==============Since both QRTR and ath drivers are falling under the networking tree, the whole series can be merged through netdev tree.
Makes sense, could you repost these after the merge window (~1 week) and tag as "PATCH net-next" then? Our CI is thrown by the wifi patches in the same series and did not ingest the series.
Signature · 1 line
pw-bot: defer