All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 3/6] qmi: lte: Support additional attributes
Date: Mon, 29 Apr 2024 10:56:55 -0500	[thread overview]
Message-ID: <20240429155726.51479-3-denkenz@gmail.com> (raw)
In-Reply-To: <20240429155726.51479-1-denkenz@gmail.com>

Add support for setting APN Type (IPV4, IPV6 or Dual), Username and
Password attributes of the profile used for the default bearer.
---
 drivers/qmimodem/lte.c | 21 +++++++++++++++++----
 drivers/qmimodem/wds.c | 14 ++++++++++++++
 drivers/qmimodem/wds.h |  1 +
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/qmimodem/lte.c b/drivers/qmimodem/lte.c
index 7633572b39ef..70efaf04c8f5 100644
--- a/drivers/qmimodem/lte.c
+++ b/drivers/qmimodem/lte.c
@@ -66,6 +66,10 @@ static void qmimodem_lte_set_default_attach_info(const struct ofono_lte *lte,
 			const struct ofono_lte_default_attach_info *info,
 			ofono_lte_cb_t cb, void *data)
 {
+	static const uint8_t PARAM_PDP_TYPE = 0x11;
+	static const uint8_t PARAM_USERNAME = 0x1B;
+	static const uint8_t PARAM_PASSWORD = 0x1C;
+	static const uint8_t PARAM_AUTHENTICATION_PREFERENCE = 0x1D;
 	struct lte_data *ldd = ofono_lte_get_data(lte);
 	struct cb_data *cbd = cb_data_new(cb, data);
 	struct qmi_param* param;
@@ -76,19 +80,28 @@ static void qmimodem_lte_set_default_attach_info(const struct ofono_lte *lte,
 		.type = QMI_WDS_PROFILE_TYPE_3GPP,
 		.index = ldd->default_profile,
 	};
+	uint8_t auth = qmi_wds_auth_from_ofono(info->auth_method);
 
 	DBG("");
 
 	param = qmi_param_new();
 
-	/* Profile selector */
 	qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
-
-	/* WDS APN Name */
+	qmi_param_append_uint8(param, PARAM_PDP_TYPE,
+				qmi_wds_pdp_type_from_ofono(info->proto));
 	qmi_param_append(param, QMI_WDS_PARAM_APN,
 				strlen(info->apn), info->apn);
 
-	/* Modify profile */
+	qmi_param_append_uint8(param, PARAM_AUTHENTICATION_PREFERENCE, auth);
+
+	if (auth && info->username[0])
+		qmi_param_append(param, PARAM_USERNAME,
+					strlen(info->username), info->username);
+
+	if (auth && info->password[0])
+		qmi_param_append(param, PARAM_PASSWORD,
+					strlen(info->password), info->password);
+
 	if (qmi_service_send(ldd->wds, QMI_WDS_MODIFY_PROFILE, param,
 					modify_profile_cb, cbd, l_free) > 0)
 		return;
diff --git a/drivers/qmimodem/wds.c b/drivers/qmimodem/wds.c
index 748ad867c2cc..d126f4712921 100644
--- a/drivers/qmimodem/wds.c
+++ b/drivers/qmimodem/wds.c
@@ -23,3 +23,17 @@ int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method)
 
 	return -ENOENT;
 }
+
+int qmi_wds_pdp_type_from_ofono(enum ofono_gprs_proto proto)
+{
+	switch (proto) {
+	case OFONO_GPRS_PROTO_IP:
+		return QMI_WDS_PDP_TYPE_IPV4;
+	case OFONO_GPRS_PROTO_IPV6:
+		return QMI_WDS_PDP_TYPE_IPV6;
+	case OFONO_GPRS_PROTO_IPV4V6:
+		return QMI_WDS_PDP_TYPE_IPV4V6;
+	}
+
+	return -ENOENT;
+}
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index c8aeefe430bb..d896fd8cc535 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -110,3 +110,4 @@ enum qmi_wds_command {
 };
 
 int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method);
+int qmi_wds_pdp_type_from_ofono(enum ofono_gprs_proto proto);
-- 
2.44.0


  parent reply	other threads:[~2024-04-29 15:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 15:56 [PATCH 1/6] qmi: lte: Remove magic number use Denis Kenzior
2024-04-29 15:56 ` [PATCH 2/6] qmi: wds: Move enum conversion into wds.c Denis Kenzior
2024-04-29 15:56 ` Denis Kenzior [this message]
2024-04-29 15:56 ` [PATCH 4/6] qmi: gprs: Query default profile number at init Denis Kenzior
2024-04-29 15:56 ` [PATCH 5/6] udevng: Add "option" module managed ports to gobi driver Denis Kenzior
2024-04-29 15:56 ` [PATCH 6/6] udevng: Support Quectel RM502Q Denis Kenzior
2024-04-29 19:10 ` [PATCH 1/6] qmi: lte: Remove magic number use 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=20240429155726.51479-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.