Skip to contentSkip to conversation

Implement data capability bearer notify

PATCH Superseded Marius Gripsgard 2 participants 3 messages Jun 9, 2020 – Jun 10, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Implement data capability bearer notify

This implements data capability bearer notify to qmi modem. Since this is included in the serving system response this just adds a new data extraction for dc.

---
 drivers/qmimodem/gprs.c | 29 +++++++++++++++++++++++++++++
 drivers/qmimodem/nas.c  | 36 ++++++++++++++++++++++++++++++++++++
 drivers/qmimodem/nas.h  | 23 +++++++++++++++++++++++
 3 files changed, 88 insertions(+)
drivers/qmimodem/gprs.c +29 -0
index 07adbe9a..0ba24da7 100644
@@ -68,6 +68,29 @@ static bool extract_ss_info(struct qmi_result *result, int *status, int *tech)
 	return true;
 }
 
+static bool extract_dc_info(struct qmi_result *result, int *bearer_tech)
+{
+	const struct qmi_nas_data_capability *dc;
+	uint16_t len;
+	int i;
+
+	DBG("");
+
+	dc = qmi_result_get(result, QMI_NAS_RESULT_DATA_CAPABILIT_STATUS, &len);
+	if (!dc)
+		return false;
+
+	*bearer_tech = -1;
+	for (i = 0; i < dc->cap_count; i++) {
+		DBG("radio tech in use %d", dc->cap[i]);
+
+		*bearer_tech = qmi_nas_cap_to_bearer_tech(dc->cap[i]);
+	}
+
+	return true;
+}
+
+
 static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data)
 {
 	struct ofono_gprs *gprs = user_data;
@@ -188,6 +211,7 @@ static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
 	struct gprs_data *data = ofono_gprs_get_data(gprs);
 	int status;
 	int tech;
+	int bearer_tech;
 
 	DBG("");
 
@@ -209,6 +233,11 @@ static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
 		data->last_auto_context_id = 0;
 	}
 
+	if (!extract_dc_info(result, &bearer_tech))
+		return -1;
+
+	ofono_gprs_bearer_notify(gprs, bearer_tech);
+
 	return status;
 }
 
drivers/qmimodem/nas.c +36 -0
index 48d7f11c..630f901d 100644
@@ -36,3 +36,39 @@ int qmi_nas_rat_to_tech(uint8_t rat)
 
 	return -1;
 }
+
+int qmi_nas_cap_to_bearer_tech(int cap_tech)
+{
+
+	switch (cap_tech) {
+	case QMI_NAS_DATA_CAPABILITY_GSM:
+	case QMI_NAS_DATA_CAPABILITY_NONE:
+		return PACKET_BEARER_NONE;
+	case QMI_NAS_DATA_CAPABILITY_GPRS:
+		return PACKET_BEARER_GPRS;
+	case QMI_NAS_DATA_CAPABILITY_EDGE:
+		return PACKET_BEARER_EGPRS;
+	case QMI_NAS_DATA_CAPABILITY_EVDO_REV_0:
+	case QMI_NAS_DATA_CAPABILITY_EVDO_REV_A:
+	case QMI_NAS_DATA_CAPABILITY_EVDO_REV_B:
+		return PACKET_BEARER_UMTS;
+	case QMI_NAS_DATA_CAPABILITY_HSDPA:
+		return PACKET_BEARER_HSDPA;
+	case QMI_NAS_DATA_CAPABILITY_HSUPA:
+		return PACKET_BEARER_HSUPA;
+    case QMI_NAS_DATA_CAPABILITY_HSDPA_PLUS:
+    case QMI_NAS_DATA_CAPABILITY_DC_HSDPA_PLUS:
+		/*
+		 * HSPAP is HSPA+; which ofono doesn't define;
+		 * so, if differentiating HSPA and HSPA+ is
+		 * important, then ofono needs to be patched,
+		 * and we probably also need to introduce a
+		 * new indicator icon.
+		 */
+		return PACKET_BEARER_HSUPA_HSDPA;
+	case QMI_NAS_DATA_CAPABILITY_LTE:
+		return PACKET_BEARER_EPS;
+	default:
+		return PACKET_BEARER_NONE;
+	}
+}
drivers/qmimodem/nas.h +23 -0
index 9f67707e..93f541b2 100644
@@ -135,6 +135,28 @@ struct qmi_nas_serving_system {
 	uint8_t radio_if[0];
 } __attribute__((__packed__));
 #define QMI_NAS_RESULT_ROAMING_STATUS		0x10	/* uint8 */
+
+#define QMI_NAS_RESULT_DATA_CAPABILIT_STATUS		0x11	/* uint8 */
+struct qmi_nas_data_capability {
+	uint8_t cap_count;
+	uint8_t cap[0];
+} __attribute__((__packed__));
+
+#define QMI_NAS_DATA_CAPABILITY_NONE          0x00
+#define QMI_NAS_DATA_CAPABILITY_GPRS          0x01
+#define QMI_NAS_DATA_CAPABILITY_EDGE          0x02
+#define QMI_NAS_DATA_CAPABILITY_HSDPA         0x03
+#define QMI_NAS_DATA_CAPABILITY_HSUPA         0x04
+#define QMI_NAS_DATA_CAPABILITY_WCDMA         0x05
+#define QMI_NAS_DATA_CAPABILITY_CDMA          0x06
+#define QMI_NAS_DATA_CAPABILITY_EVDO_REV_0    0x07
+#define QMI_NAS_DATA_CAPABILITY_EVDO_REV_A    0x08
+#define QMI_NAS_DATA_CAPABILITY_GSM           0x09
+#define QMI_NAS_DATA_CAPABILITY_EVDO_REV_B    0x0A
+#define QMI_NAS_DATA_CAPABILITY_LTE           0x0B
+#define QMI_NAS_DATA_CAPABILITY_HSDPA_PLUS    0x0C
+#define QMI_NAS_DATA_CAPABILITY_DC_HSDPA_PLUS 0x0D
+
 #define QMI_NAS_RESULT_CURRENT_PLMN		0x12
 struct qmi_nas_current_plmn {
 	uint16_t mcc;
@@ -188,3 +210,4 @@ struct qmi_nas_home_network {
 #define QMI_NAS_RESULT_SYSTEM_SELECTION_PREF_MODE	0x11
 
 int qmi_nas_rat_to_tech(uint8_t rat);
+int qmi_nas_cap_to_bearer_tech(int cap_tech);
Signature · 1 line
2.25.1
#1 lore raw

Hi Marius,

Quoted 9 lines · Marius Gripsgard

This implements data capability bearer notify to qmi modem. Since this is included in the serving system response this just adds a new data extraction for dc.

---
  drivers/qmimodem/gprs.c | 29 +++++++++++++++++++++++++++++
  drivers/qmimodem/nas.c  | 36 ++++++++++++++++++++++++++++++++++++
  drivers/qmimodem/nas.h  | 23 +++++++++++++++++++++++
  3 files changed, 88 insertions(+)

Looks good, just couple of nitpicks:

Quoted 7 lines
drivers/qmimodem/gprs.c +0 -0
index 07adbe9a..0ba24da7 100644
@@ -68,6 +68,29 @@ static bool extract_ss_info(struct qmi_result *result, int *status, int *tech)
  	return true;
  }

drivers/qmimodem/gprs.c static bool extract_ss_info(struct qmi_result *result, int *status, int *tech) · line 79

Quoted 10 lines
drivers/qmimodem/gprs.c +9 -0
 
+static bool extract_dc_info(struct qmi_result *result, int *bearer_tech)
+{
+	const struct qmi_nas_data_capability *dc;
+	uint16_t len;
+	int i;
+
+	DBG("");
+
+	dc = qmi_result_get(result, QMI_NAS_RESULT_DATA_CAPABILIT_STATUS, &len);

Should this be CAPABILITY?

drivers/qmimodem/gprs.c static bool extract_ss_info(struct qmi_result *result, int *status, int *tech) · line 87

Quoted 8 lines
drivers/qmimodem/gprs.c +8 -0
+	if (!dc)
+		return false;
+
+	*bearer_tech = -1;
+	for (i = 0; i < dc->cap_count; i++) {
+		DBG("radio tech in use %d", dc->cap[i]);
+
+		*bearer_tech = qmi_nas_cap_to_bearer_tech(dc->cap[i]);

I'm fine with this, but out of curiosity: can there be multiple of these? Are they sorted somehow?

drivers/qmimodem/gprs.c static bool extract_ss_info(struct qmi_result *result, int *status, int *tech) · line 93

Quoted 6 lines
drivers/qmimodem/gprs.c +6 -0
+	}
+
+	return true;
+}
+
+

No double empty lines please

Quoted 12 lines
drivers/qmimodem/gprs.c +1 -0
  static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data)
  {
  	struct ofono_gprs *gprs = user_data;
@@ -188,6 +211,7 @@ static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
  	struct gprs_data *data = ofono_gprs_get_data(gprs);
  	int status;
  	int tech;
+	int bearer_tech;
 
  	DBG("");
 

drivers/qmimodem/gprs.c static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs) · line 237

Quoted 5 lines
drivers/qmimodem/gprs.c +2 -0
@@ -209,6 +233,11 @@ static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
  		data->last_auto_context_id = 0;
  	}
 
+	if (!extract_dc_info(result, &bearer_tech))
+		return -1;

So bearer_tech is pretty much optional, are you sure you want to return an error here if the extraction fails? Maybe something like:

if (extract_dc_info(result, &bearer_tech)

	ofono_grps_bearer_notify(gprs, bearer_tech);

would be a bit more conservative.

drivers/qmimodem/gprs.c static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs) · line 243

Quoted 6 lines
drivers/qmimodem/gprs.c +3 -0
+
+	ofono_gprs_bearer_notify(gprs, bearer_tech);
+
  	return status;
  }
 

Regards,
-Denis

#2 lore raw

Hi Denis

v2 patch sent with fixes :)

Quoted 28 lines · Denis Kenzior

Hi Marius,

Quoted 9 lines · Marius Gripsgard

This implements data capability bearer notify to qmi modem. Since this is included in the serving system response this just adds a new data extraction for dc.
---
  drivers/qmimodem/gprs.c | 29 +++++++++++++++++++++++++++++ drivers/qmimodem/nas.c  | 36 ++++++++++++++++++++++++++++++++++++ drivers/qmimodem/nas.h  | 23 +++++++++++++++++++++++

  3 files changed, 88 insertions(+)

Looks good, just couple of nitpicks:

Quoted 13 lines
drivers/qmimodem/gprs.c +0 -0
index 07adbe9a..0ba24da7 100644
@@ -68,6 +68,29 @@ static bool extract_ss_info(struct qmi_result
 *result, int *status, int *tech)
       return true;
   }

  +static bool extract_dc_info(struct qmi_result *result, int *bearer_tech)
+{
+    const struct qmi_nas_data_capability *dc;
+    uint16_t len;

Quoted 8 lines
Quoted 6 lines

+    int i;

drivers/qmimodem/gprs.c +4 -0
+
+    DBG("");
+
+    dc = qmi_result_get(result,

QMI_NAS_RESULT_DATA_CAPABILIT_STATUS, &len);

Should this be CAPABILITY?

Yes :)

Quoted 12 lines

drivers/qmimodem/gprs.c static bool extract_ss_info(struct qmi_result *result, int *status, int *tech) · line 87

Quoted 9 lines

+    if (!dc)
+        return false;

drivers/qmimodem/gprs.c +6 -0
+
+    *bearer_tech = -1;
+    for (i = 0; i < dc->cap_count; i++) {
+        DBG("radio tech in use %d", dc->cap[i]);
+
+        *bearer_tech = qmi_nas_cap_to_bearer_tech(dc->cap[i]);

I'm fine with this, but out of curiosity: can there be multiple of these?  Are they sorted somehow?

There can be more then one sim, but qmimodem currently does not handle it. This is not the most pretty way of handling it, but i wanted to at least print all of them but use the last one (as that should be the last one in use). I also wanted to follow the same style as used above.

We could do dc->cap[cap_count-1], but would be nice to have both extractions similar.

Quoted 9 lines

drivers/qmimodem/gprs.c static bool extract_ss_info(struct qmi_result *result, int *status, int *tech) · line 93

Quoted 7 lines

+    }

drivers/qmimodem/gprs.c +5 -0
+
+    return true;
+}
+
+

No double empty lines please

Wops, didn't see those

Quoted 22 lines
Quoted 12 lines

  static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data)
  {
      struct ofono_gprs *gprs = user_data;

drivers/qmimodem/gprs.c +1 -0
@@ -188,6 +211,7 @@ static int handle_ss_info(struct qmi_result
 *result, struct ofono_gprs *gprs)
       struct gprs_data *data = ofono_gprs_get_data(gprs);
       int status;
       int tech;
+    int bearer_tech;
         DBG("");
Quoted 6 lines

  @@ -209,6 +233,11 @@ static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs) data->last_auto_context_id = 0;
      }
  +    if (!extract_dc_info(result, &bearer_tech))
+        return -1;

So bearer_tech is pretty much optional, are you sure you want to return an error here if the extraction fails?  Maybe something like:

Quoted 4 lines

if (extract_dc_info(result, &bearer_tech)
    ofono_grps_bearer_notify(gprs, bearer_tech);

would be a bit more conservative.

Yes i agree, we should still return ss return value even if bearer is not available.

Quoted 13 lines
Quoted 7 lines
drivers/qmimodem/gprs.c +3 -0
+
+    ofono_gprs_bearer_notify(gprs, bearer_tech);
+

      return status;
  }

Regards,
-Denis
_______________________________________________
ofono mailing list -- ofono(a)ofono.org
To unsubscribe send an email to ofono-leave(a)ofono.org