ATH11K Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mihai Moldovan <ionic@ionic.de>
To: ath11k@lists.infradead.org
Subject: [RFC] [PATCH 06/13] soc: qcom: qmi_helpers: optionally bind to QRTR endpoint ID in qmi_sock_create
Date: Sun, 17 Nov 2024 17:06:05 +0100	[thread overview]
Message-ID: <44b42c271593a5dc421e96887617af390bca997c.1731858974.git.ionic@ionic.de> (raw)
In-Reply-To: <cover.1731858971.git.ionic@ionic.de>

For clients that already know the QRTR endpoint ID before actually
creating the QMI socket and set it in struct qmi_handle, optionally try
to bind to this QRTR endpoint ID when creating the socket.

This can fail, and qmi_sock_create will issue diagnostic messages, but
otherwise ignore the error.

Signed-off-by: Mihai Moldovan <ionic@ionic.de>
---
 drivers/soc/qcom/qmi_interface.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c
index bb98b06e87f8..893e5a6accd9 100644
--- a/drivers/soc/qcom/qmi_interface.c
+++ b/drivers/soc/qcom/qmi_interface.c
@@ -586,6 +586,7 @@ static struct socket *qmi_sock_create(struct qmi_handle *qmi,
 				      struct sockaddr_qrtr *sq)
 {
 	struct socket *sock;
+	const struct proto_ops *ops = NULL;
 	int ret;
 
 	ret = sock_create_kern(&init_net, AF_QIPCRTR, SOCK_DGRAM,
@@ -593,6 +594,33 @@ static struct socket *qmi_sock_create(struct qmi_handle *qmi,
 	if (ret < 0)
 		return ERR_PTR(ret);
 
+	ops = READ_ONCE(sock->ops);
+
+	if (!ops) {
+		pr_warn("sock->ops not available for QMI socket, will not be "
+			"able to bind to endpoint ID.\n");
+		/* N.B.: this error value will not be passed out. */
+		ret = -ENXIO;
+	}
+
+	if (!ret && !ops->setsockopt) {
+		pr_warn("ops->setsockopt not available for QMI socket, will "
+			"not be able to bind to endpoint ID.\n");
+		/* N.B.: this error value will not be passed out. */
+		ret = -ENXIO;
+	}
+
+	/* Only bind to a specific endpoint if a valid one was provided. */
+	if (!ret && qmi->endpoint_id) {
+		ret = ops->setsockopt(sock, SOL_QRTR, QRTR_BIND_ENDPOINT,
+				      KERNEL_SOCKPTR(&qmi->endpoint_id),
+				      sizeof(qmi->endpoint_id));
+
+		if (ret < 0)
+			pr_warn("binding to QRTR endpoint ID requested, but "
+				"operation failed: %d\n", ret);
+	}
+
 	ret = kernel_getsockname(sock, (struct sockaddr *)sq);
 	if (ret < 0) {
 		sock_release(sock);
-- 
2.45.2



  parent reply	other threads:[~2024-11-17 16:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-17 16:05 [RFC] [PATCH 00/13] ath1{1,2}k: support multiple PCI devices in one system Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 01/13] net: qrtr: support registering endpoint-specific data Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 02/13] net: qrtr: mhi: register mhi_controller as " Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 03/13] net: qrtr: smd: register rpmsg_device " Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 04/13] net: qrtr: tun: register inode " Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 05/13] soc: qcom: qmi_helpers: add QRTR endpoint ID to qmi_handle Mihai Moldovan
2024-11-17 16:06 ` Mihai Moldovan [this message]
2024-11-17 16:06 ` [RFC] [PATCH 07/13] wifi: ath11k: add QRTR endpoint ID hif feature Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 08/13] wifi: ath11k: stub QRTR endpoint ID fetching for AHB Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 09/13] wifi: ath11k: implement QRTR endpoint ID fetching for PCI Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 10/13] wifi: ath11k: bind to QRTR endpoint ID in ath11k_qmi_init_service Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 11/13] wifi: ath12k: add QRTR endpoint ID hif feature Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 12/13] wifi: ath12k: implement QRTR endpoint ID fetching for PCI Mihai Moldovan
2024-11-17 16:06 ` [RFC] [PATCH 13/13] wifi: ath12k: bind to QRTR endpoint ID in ath12k_qmi_init_service Mihai Moldovan
2024-11-17 16:59 ` [RFC] [PATCH 00/13] ath1{1,2}k: support multiple PCI devices in one system Mihai Moldovan
2024-11-18 15:52   ` Jeff Johnson
2024-11-22 16:40     ` Jeff Johnson
2024-11-22 20:05       ` Mihai Moldovan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44b42c271593a5dc421e96887617af390bca997c.1731858974.git.ionic@ionic.de \
    --to=ionic@ionic.de \
    --cc=ath11k@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox