($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 8/8] qmi: gprs-context: Obtain initial bearer IP support
Date: Mon,  6 May 2024 16:58:02 -0500	[thread overview]
Message-ID: <20240506215804.57124-8-denkenz@gmail.com> (raw)
In-Reply-To: <20240506215804.57124-1-denkenz@gmail.com>

.read_settings is used by the core to setup the network interface for
the initial bearer.  This initial bearer is typically an internet
context, but can be something else, depending on the carrier.  The
initial bearer might also be configured by the network itself, and can
be IPv4, IPv6 or dual stack.  Have the gprs-context driver query the
initial attach parameters to obtain this information, and only then
invoke the WDS Start Network command.

Supporting Dual Stack contexts requires multiple WDS handles to be
allocated, with each handle issuing a Start Network request with a
different IP family preference.  This is currently not supported by the
underlying QMUX/QRTR transport.  For now, choose invoke Start Network
with IPv4 family preference for IPV4 and Dual Stack contexts, and IPv6
famiily preference for IPv6 contexts.
---
 drivers/qmimodem/gprs-context.c | 64 ++++++++++++++++++++++++++++-----
 drivers/qmimodem/wds.h          |  6 ++++
 2 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 21ef1237758e..e04821c3ca6d 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -282,6 +282,55 @@ error:
 	CALLBACK_WITH_FAILURE(cb, cbd->data);
 }
 
+static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data)
+{
+	static const uint8_t RESULT_IP_SUPPORT_TYPE = 0x11;
+	struct cb_data *cbd = user_data;
+	ofono_gprs_context_cb_t cb = cbd->cb;
+	struct ofono_gprs_context *gc = cbd->user;
+	struct gprs_context_data *data = ofono_gprs_context_get_data(gc);
+	uint16_t error;
+	uint8_t iptype;
+	struct qmi_param *param;
+	uint8_t ip_family;
+
+	DBG("");
+
+	if (qmi_result_set_error(result, &error))
+		goto error;
+
+	if (!qmi_result_get_uint8(result, RESULT_IP_SUPPORT_TYPE, &iptype))
+		goto error;
+
+	switch (iptype) {
+	case QMI_WDS_IP_SUPPORT_IPV4:
+		ip_family = QMI_WDS_IP_FAMILY_IPV4;
+		break;
+	case QMI_WDS_IP_SUPPORT_IPV6:
+		ip_family = QMI_WDS_IP_FAMILY_IPV6;
+		break;
+	case QMI_WDS_IP_SUPPORT_IPV4V6:
+		ip_family = QMI_WDS_IP_FAMILY_IPV4;
+		break;
+	default:
+		goto error;
+	}
+
+	param = qmi_param_new_uint8(QMI_WDS_PARAM_IP_FAMILY, ip_family);
+
+	if (qmi_service_send(data->wds, QMI_WDS_START_NETWORK, param,
+					start_net_cb, cbd, cb_data_unref) > 0) {
+		cb_data_ref(cbd);
+		return;
+	}
+
+	qmi_param_free(param);
+
+error:
+	data->active_context = 0;
+	CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
 /*
  * This function gets called for "automatic" contexts, those which are
  * not activated via activate_primary.  For these, we will still need
@@ -299,18 +348,15 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc,
 
 	DBG("cid %u", cid);
 
-	data->active_context = cid;
-
-	cbd->user = gc;
-
-	if (qmi_service_send(data->wds, QMI_WDS_START_NETWORK, NULL,
-					start_net_cb, cbd, cb_data_unref) > 0)
+	if (qmi_service_send(data->wds, QMI_WDS_GET_LTE_ATTACH_PARAMETERS,
+				NULL, get_lte_attach_param_cb, cbd,
+				cb_data_unref) > 0) {
+		data->active_context = cid;
+		cbd->user = gc;
 		return;
-
-	data->active_context = 0;
+	}
 
 	CALLBACK_WITH_FAILURE(cb, cbd->data);
-
 	l_free(cbd);
 }
 
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index 026402e7a3f6..a308767177a3 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -46,6 +46,12 @@ enum qmi_wds_pdp_type {
 	QMI_WDS_PDP_TYPE_IPV4V6		= 0x03,
 };
 
+enum qmi_wds_ip_support {
+	QMI_WDS_IP_SUPPORT_IPV4		= 0x00,
+	QMI_WDS_IP_SUPPORT_IPV6		= 0x01,
+	QMI_WDS_IP_SUPPORT_IPV4V6	= 0x02,
+};
+
 enum qmi_wds_ip_family {
 	QMI_WDS_IP_FAMILY_UNKNOWN = 0,
 	QMI_WDS_IP_FAMILY_IPV4 = 4,
-- 
2.45.0


  parent reply	other threads:[~2024-05-06 21:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 21:57 [PATCH v2 1/8] qmi: wds: Fix up enum naming Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 2/8] qmi: gprs: use Extended Data Bearer Technology Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 3/8] qmi: netreg: Print network capability Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 4/8] qmi: gprs: Remove IP Support Type parsing Denis Kenzior
2024-05-06 21:57 ` [PATCH v2 5/8] qmi: gprs: Remove magic number use Denis Kenzior
2024-05-06 21:58 ` [PATCH v2 6/8] qmi: gprs-context: Split out IPv4 setting processing Denis Kenzior
2024-05-06 21:58 ` [PATCH v2 7/8] qmi: gprs-context: Parse IPv6 context settings Denis Kenzior
2024-05-06 21:58 ` Denis Kenzior [this message]
2024-05-06 23:20 ` [PATCH v2 1/8] qmi: wds: Fix up enum naming patchwork-bot+ofono

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=20240506215804.57124-8-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@lists.linux.dev \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).