($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 2/8] qmi: gprs: use Extended Data Bearer Technology
Date: Mon,  6 May 2024 16:57:56 -0500	[thread overview]
Message-ID: <20240506215804.57124-2-denkenz@gmail.com> (raw)
In-Reply-To: <20240506215804.57124-1-denkenz@gmail.com>

This TLV is reported by WDS "Event Report" indication and contains a
better representation of the current bearer compared to the Data Service
Capability TLV reported in the NAS Serving System indication.

 TLV:
   type       = "Extended Data Bearer Technology" (0x2a)
   length     = 16
   value      = 00:00:00:00:03:00:00:00:00:10:00:00:00:00:00:00
   translated = [ data_bearer_technology = '3gpp'
 		  radio_access_technology = '3gpp-lte'
		  extended_data_bearer_technology_3gpp = 'lte-fdd'
		  ...]

 TLV:
   type       = "Data Service Capability" (0x11)
   length     = 2
   value      = 01:0B
   translated = { [0] = 'lte '}

Some of the 5G and more esoteric technologies are not yet handled in
this commit.  Support for these technologies needs to be added in the
core first.

Modify the logic in the gprs driver to use this new mechanism.
---
 drivers/qmimodem/gprs.c | 20 ++++++++++++---
 drivers/qmimodem/wds.c  | 55 +++++++++++++++++++++++++++++++++++++++++
 drivers/qmimodem/wds.h  | 39 +++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 3 deletions(-)

diff --git a/drivers/qmimodem/gprs.c b/drivers/qmimodem/gprs.c
index ebb235545e21..e406eba3b19a 100644
--- a/drivers/qmimodem/gprs.c
+++ b/drivers/qmimodem/gprs.c
@@ -151,9 +151,7 @@ static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
 	if (!extract_ss_info(result, &status, &tech))
 		return -1;
 
-	/* DC is optional so only notify on successful extraction */
-	if (extract_dc_info(result, &bearer_tech))
-		ofono_gprs_bearer_notify(gprs, bearer_tech);
+	extract_dc_info(result, &bearer_tech);
 
 	return status;
 }
@@ -174,6 +172,7 @@ static void ss_info_notify(struct qmi_result *result, void *user_data)
 static void event_report_notify(struct qmi_result *result, void *user_data)
 {
 	static const uint8_t RESULT_DATA_SYSTEM_STATUS = 0x24;
+	static const uint8_t RESULT_EXTENDED_DATA_BEARER_TECHNOLOGY = 0x2a;
 	struct ofono_gprs *gprs = user_data;
 	const void *tlv;
 	uint16_t len;
@@ -198,6 +197,21 @@ static void event_report_notify(struct qmi_result *result, void *user_data)
 		return;
 	}
 
+	tlv = qmi_result_get(result,
+				RESULT_EXTENDED_DATA_BEARER_TECHNOLOGY, &len);
+	if (tlv) {
+		int r = qmi_wds_parse_extended_data_bearer_technology(tlv, len);
+
+		if (r < 0) {
+			ofono_warn("extended_data_bearer_technology: %s(%d)",
+					strerror(-r), r);
+			return;
+		}
+
+		ofono_gprs_bearer_notify(gprs, r);
+		return;
+	}
+
 	qmi_result_print_tlvs(result);
 }
 
diff --git a/drivers/qmimodem/wds.c b/drivers/qmimodem/wds.c
index 77e22f443db0..ced0c5e5308d 100644
--- a/drivers/qmimodem/wds.c
+++ b/drivers/qmimodem/wds.c
@@ -75,3 +75,58 @@ int qmi_wds_parse_data_system_status(const void *dss, uint16_t len)
 
 	return -ENOENT;
 }
+
+int qmi_wds_parse_extended_data_bearer_technology(const void *edbt, uint16_t len)
+{
+	uint32_t technology;
+	uint32_t rat;
+	uint32_t so;
+	int bearer;
+
+	if (len != sizeof(uint32_t) * 2 + sizeof(uint64_t))
+		return -EBADMSG;
+
+	technology = l_get_le32(edbt);
+	rat = l_get_le32(edbt + sizeof(uint32_t));
+	so = l_get_le64(edbt + sizeof(uint32_t) * 2);
+
+	if (technology != QMI_WDS_PROFILE_TYPE_3GPP)
+		return -EINVAL;
+
+	switch (rat) {
+	case QMI_WDS_RAT_WCDMA:
+		bearer = PACKET_BEARER_UMTS;
+		break;
+	case QMI_WDS_RAT_LTE:
+		bearer = PACKET_BEARER_EPS;
+		break;
+	default:
+		return -ENOENT;
+	}
+
+	if (so & (QMI_WDS_SO_LTE_LIMITED | QMI_WDS_SO_LTE_FDD |
+			QMI_WDS_SO_LTE_TDD))
+		return PACKET_BEARER_EPS;
+
+	if (so & (QMI_WDS_SO_HSDPAPLUS | QMI_WDS_SO_DC_HSDPAPLUS |
+			QMI_WDS_SO_64_QAM | QMI_WDS_SO_HSPA))
+		return PACKET_BEARER_HSUPA_HSDPA;
+
+	if (so & (QMI_WDS_SO_HSUPA | QMI_WDS_SO_DC_HSUPA))
+		return PACKET_BEARER_HSUPA;
+
+	if (so & QMI_WDS_SO_HSDPA)
+		return PACKET_BEARER_HSDPA;
+
+	if (so & QMI_WDS_SO_WCDMA)
+		return PACKET_BEARER_UMTS;
+
+	if (so & QMI_WDS_SO_EDGE)
+		return PACKET_BEARER_EGPRS;
+
+	if (so & QMI_WDS_SO_GPRS)
+		return PACKET_BEARER_GPRS;
+
+	/* Fall back to rat */
+	return bearer;
+}
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index 218587c3e437..026402e7a3f6 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -83,6 +83,43 @@ enum qmi_wds_rat_3gpp {
 	QMI_WDS_RAT_3GPP_NULL_BEARER		= 0x8000,
 };
 
+enum qmi_wds_rat {
+	QMI_WDS_RAT_WCDMA			= 0x01,
+	QMI_WDS_RAT_GERAN			= 0x02,
+	QMI_WDS_RAT_LTE				= 0x03,
+	QMI_WDS_RAT_TDSCDMA			= 0x04,
+	QMI_WDS_RAT_WLAN			= 0x05,
+};
+
+enum qmi_wds_service_option {
+	QMI_WDS_SO_WCDMA			= 0x01ULL,
+	QMI_WDS_SO_HSDPA			= 0x02ULL,
+	QMI_WDS_SO_HSUPA			= 0x04ULL,
+	QMI_WDS_SO_HSDPAPLUS			= 0x08ULL,
+	QMI_WDS_SO_DC_HSDPAPLUS			= 0x10ULL,
+	QMI_WDS_SO_64_QAM			= 0x20ULL,
+	QMI_WDS_SO_HSPA				= 0x40ULL,
+	QMI_WDS_SO_GPRS				= 0x80ULL,
+	QMI_WDS_SO_EDGE				= 0x100ULL,
+	QMI_WDS_SO_GSM				= 0x200ULL,
+	QMI_WDS_SO_S2B				= 0x400ULL,
+	QMI_WDS_SO_LTE_LIMITED			= 0x800ULL,
+	QMI_WDS_SO_LTE_FDD			= 0x1000ULL,
+	QMI_WDS_SO_LTE_TDD			= 0x2000ULL,
+	QMI_WDS_SO_TDSCDMA			= 0x4000ULL,
+	QMI_WDS_SO_DC_HSUPA			= 0x8000ULL,
+	QMI_WDS_SO_LTE_CA_DL			= 0x10000ULL,
+	QMI_WDS_SO_LTE_CA_UL			= 0x20000ULL,
+	QMI_WDS_SO_S2B_LIMITED			= 0x40000ULL,
+	QMI_WDS_SO_FOUR_POINT_FIVE_G		= 0x80000ULL,
+	QMI_WDS_SO_FOUR_POINT_FIVE_G_PLUS	= 0x100000ULL,
+	QMI_WDS_SO_5G_TDD			= 0x10000000000ULL,
+	QMI_WDS_SO_5G_SUB6			= 0x20000000000ULL,
+	QMI_WDS_SO_5G_MMWAVE			= 0x40000000000ULL,
+	QMI_WDS_SO_5G_NSA			= 0x80000000000ULL,
+	QMI_WDS_SO_5G_SA			= 0x100000000000ULL,
+};
+
 enum qmi_wds_command {
 	QMI_WDS_RESET					= 0x00,
 	QMI_WDS_EVENT_REPORT				= 0x01,
@@ -128,3 +165,5 @@ int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method);
 int qmi_wds_pdp_type_from_ofono(enum ofono_gprs_proto proto);
 
 int qmi_wds_parse_data_system_status(const void *dss, uint16_t len);
+int qmi_wds_parse_extended_data_bearer_technology(const void *edbt,
+							uint16_t len);
-- 
2.45.0


  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 ` Denis Kenzior [this message]
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 ` [PATCH v2 8/8] qmi: gprs-context: Obtain initial bearer IP support Denis Kenzior
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-2-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).