diff mbox series

[v2,6/6] qmi: gprs: Obtain LTE attach parameters after indication

Message ID 20240501232144.14025-6-denkenz@gmail.com (mailing list archive)
State Accepted
Commit c12a6251b1fb8044de6bb379c38b9024c33bd3a7
Headers show
Series [v2,1/6] qmi: gprs: register to NAS indications earlier | expand

Commit Message

Denis Kenzior May 1, 2024, 11:21 p.m. UTC
It seems this TLV/Indication combination is needed in order for the
GET_LTE_ATTACH_PARAMETERS command to succeed:
ofonod[3257238]: Failed to query LTE attach params: 74
ofonod[3257238]: LTE bearer established but APN not set
---
 drivers/qmimodem/gprs.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/gprs.c b/drivers/qmimodem/gprs.c
index 6bb5879199e6..ebb235545e21 100644
--- a/drivers/qmimodem/gprs.c
+++ b/drivers/qmimodem/gprs.c
@@ -151,19 +151,6 @@  static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
 	if (!extract_ss_info(result, &status, &tech))
 		return -1;
 
-	if (status == NETWORK_REGISTRATION_STATUS_REGISTERED) {
-		if (tech == ACCESS_TECHNOLOGY_EUTRAN) {
-			/* On LTE we are effectively always attached; and
-			 * the default bearer is established as soon as the
-			 * network is joined.  We just need to query the
-			 * parameters in effect on the default bearer and
-			 * let the ofono core know about the activated
-			 * context.
-			 */
-			get_lte_attach_params(gprs);
-		}
-	}
-
 	/* DC is optional so only notify on successful extraction */
 	if (extract_dc_info(result, &bearer_tech))
 		ofono_gprs_bearer_notify(gprs, bearer_tech);
@@ -186,8 +173,31 @@  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;
+	struct ofono_gprs *gprs = user_data;
+	const void *tlv;
+	uint16_t len;
+
 	DBG("");
 
+	/*
+	 * On LTE we are effectively always attached; and the default bearer is
+	 * established as soon as the network is joined.  We just need to query
+	 * the parameters in effect on the default bearer and let the ofono core
+	 * know about the activated context.
+	 */
+	tlv = qmi_result_get(result, RESULT_DATA_SYSTEM_STATUS, &len);
+	if (tlv) {
+		int r = qmi_wds_parse_data_system_status(tlv, len);
+		static const uint32_t lte_5g = QMI_WDS_RAT_3GPP_LTE |
+						QMI_WDS_RAT_3GPP_5GNR;
+
+		if (r >= 0 && (r & lte_5g))
+			get_lte_attach_params(gprs);
+
+		return;
+	}
+
 	qmi_result_print_tlvs(result);
 }