Skip to contentSkip to conversation

[PATCH v5 0/4]

PATCH In review Bing Jupiter 4 participants 13 messages May 12, 2021 – Aug 19, 2021

lore
Share & tools
lore
#0 lore raw

v5 cover [PATCH v5 0/4]

Cleaned up comments and resubmit

Bing Jupiter (4):
Detect SARA R4 QMI device
Detect SARA R4 QMI device
Detect SARA R4 QMI device
Detect SARA R4 QMI device

 drivers/atmodem/vendor.h |  1 +
 drivers/qmimodem/gprs.c  | 10 ++++++++++
 plugins/gobi.c           | 11 ++++++++++-
 plugins/udevng.c         | 42 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 1/4 Detect SARA R4 QMI device

---
 plugins/udevng.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
plugins/udevng.c +42 -0
index 34ac1cc0..46bf5532 100644
@@ -1194,6 +1194,46 @@ static gboolean setup_ublox(struct modem_info *modem)
 	return TRUE;
 }
 
+static gboolean setup_ubloxqmi(struct modem_info *modem) {
+	const char *qmi = NULL, *net = NULL, *gps = NULL, *aux = NULL;
+	GSList *list;
+
+	DBG("%s", modem->syspath);
+
+	for (list = modem->devices; list; list = g_slist_next(list)) {
+		struct device_info *info = list->data;
+
+		DBG("%s %s %s %s %s", info->devnode, info->interface,
+				info->number, info->label, info->subsystem);
+
+		if (g_strcmp0(info->interface, "255/255/255") == 0 &&
+				g_strcmp0(info->number, "03") == 0) {
+			if (g_strcmp0(info->subsystem, "net") == 0)
+				net = info->devnode;
+			else if (g_strcmp0(info->subsystem, "usbmisc") == 0)
+				qmi = info->devnode;
+		}
+	}
+
+	DBG("qmi=%s net=%s", qmi, net);
+
+	if (qmi == NULL || net == NULL)
+		return FALSE;
+
+	DBG("qmi=%s net=%s", qmi, net);
+
+	ofono_modem_set_string(modem->modem, "Device", qmi);
+	ofono_modem_set_string(modem->modem, "NetworkInterface", net);
+    ofono_modem_set_string(modem->modem, "Quirk", "SARAR4");
+
+
+	DBG("gps=%s aux=%s", gps, aux);
+
+	ofono_modem_set_driver(modem->modem, "gobi");
+
+	return TRUE;
+}
+
 static gboolean setup_gemalto(struct modem_info* modem)
 {
 	const char *app = NULL, *gps = NULL, *mdm = NULL,
@@ -1441,6 +1481,7 @@ static struct {
 	{ "quectel",	setup_quectel	},
 	{ "quectelqmi",	setup_quectelqmi},
 	{ "ublox",	setup_ublox	},
+    { "ubloxqmi",   setup_ubloxqmi  },
 	{ "gemalto",	setup_gemalto	},
 	{ "xmm7xxx",	setup_xmm7xxx	},
 	{ "mbim",	setup_mbim	},
@@ -1850,6 +1891,7 @@ static struct {
 	{ "ublox",	"cdc_ncm",	"1546", "110a"	},
 	{ "ublox",	"rndis_host",	"1546", "1146"	},
 	{ "ublox",	"cdc_acm",	"1546", "1146"	},
+    { "ubloxqmi",   "qmi_wwan", "05c6", "90b2"  },
 	{ "gemalto",	"option",	"1e2d",	"0053"	},
 	{ "gemalto",	"cdc_wdm",	"1e2d",	"0053"	},
 	{ "gemalto",	"qmi_wwan",	"1e2d",	"0053"	},
Signature · 1 line
2.25.1
#4 lore raw

PATCH v5 2/4 Detect SARA R4 QMI device

In reply to Bing Jupiter
---
 drivers/atmodem/vendor.h | 1 +
 1 file changed, 1 insertion(+)
drivers/atmodem/vendor.h +1 -0
index 82284e44..38613679 100644
@@ -48,6 +48,7 @@ enum ofono_vendor {
 	OFONO_VENDOR_QUECTEL_EC2X,
 	OFONO_VENDOR_QUECTEL_SERIAL,
 	OFONO_VENDOR_UBLOX,
+    OFONO_VENDOR_UBLOX_SARA_R4,
 	OFONO_VENDOR_XMM,
 	OFONO_VENDOR_GEMALTO,
 };
Signature · 1 line
2.25.1
#6 lore raw

PATCH v5 3/4 Detect SARA R4 QMI device

In reply to Bing Jupiter
---
 drivers/qmimodem/gprs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/qmimodem/gprs.c +10 -0
index 896a9e4c..fa20b809 100644
@@ -26,6 +26,7 @@
 #include <ofono/log.h>
 #include <ofono/modem.h>
 #include <ofono/gprs.h>
+#include <drivers/atmodem/vendor.h>
 
 #include "qmi.h"
 #include "nas.h"
@@ -35,6 +36,7 @@
 #include "qmimodem.h"
 
 struct gprs_data {
+    unsigned int vendor;
 	struct qmi_device *dev;
 	struct qmi_service *nas;
 	struct qmi_service *wds;
@@ -284,6 +286,13 @@ static void qmi_set_attached(struct ofono_gprs *gprs, int attached,
 
 	DBG("attached %d", attached);
 
+    if (data->vendor == OFONO_VENDOR_UBLOX_SARA_R4) {
+	    DBG("Debug vendor = OFONO_VENDOR_UBLOX_SARA_R4");
+        CALLBACK_WITH_SUCCESS(cb, cbd->data);
+        g_free(cbd);
+        return;
+    }
+    
 	if (attached)
 		action = QMI_NAS_ATTACH_ACTION_ATTACH;
 	else
@@ -406,6 +415,7 @@ static int qmi_gprs_probe(struct ofono_gprs *gprs,
 	DBG("");
 
 	data = g_new0(struct gprs_data, 1);
+    data->vendor = vendor;
 
 	ofono_gprs_set_data(gprs, data);
 
Signature · 1 line
2.25.1
#8 lore raw

PATCH v5 4/4 Detect SARA R4 QMI device

In reply to Bing Jupiter
---
 plugins/gobi.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
plugins/gobi.c +10 -1
index 9b5d7cff..5472dd83 100644
@@ -47,6 +47,7 @@
 #include <ofono/location-reporting.h>
 #include <ofono/log.h>
 #include <ofono/message-waiting.h>
+#include <drivers/atmodem/vendor.h>
 
 #include <drivers/qmimodem/qmi.h>
 #include <drivers/qmimodem/dms.h>
@@ -496,9 +497,17 @@ static void gobi_post_online(struct ofono_modem *modem)
 	struct gobi_data *data = ofono_modem_get_data(modem);
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+    const char* quirk;
+    unsigned int vendor = 0;
 
 	DBG("%p", modem);
 
+    quirk = ofono_modem_get_string(modem, "Quirk");
+    if (quirk) {
+	    DBG("Debug: vendor = OFONO_VENDOR_UBLOX_SARA_R4");
+        vendor = OFONO_VENDOR_UBLOX_SARA_R4;
+    }
+
 	if (data->features & GOBI_NAS) {
 		ofono_netreg_create(modem, 0, "qmimodem", data->device);
 		ofono_netmon_create(modem, 0, "qmimodem", data->device);
@@ -508,7 +517,7 @@ static void gobi_post_online(struct ofono_modem *modem)
 		ofono_ussd_create(modem, 0, "qmimodem", data->device);
 
 	if (data->features & GOBI_WDS) {
-		gprs = ofono_gprs_create(modem, 0, "qmimodem", data->device);
+		gprs = ofono_gprs_create(modem, vendor, "qmimodem", data->device);
 		gc = ofono_gprs_context_create(modem, 0, "qmimodem",
 							data->device);
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v5 1/4] Detect SARA R4 QMI device

In reply to Bing Jupiter

Hello,

I didn't go through the whole patch but I think you mixed 4 spaces with tab.

The same problem exist in your 4 patches.

Best Regards,

Christophe

Quoted 33 lines · Bing Jupiter
---
 plugins/udevng.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
plugins/udevng.c +21 -0
index 34ac1cc0..46bf5532 100644
@@ -1194,6 +1194,46 @@ static gboolean setup_ublox(struct modem_info *modem)
 	return TRUE;
 }
 
+static gboolean setup_ubloxqmi(struct modem_info *modem) {
+	const char *qmi = NULL, *net = NULL, *gps = NULL, *aux = NULL;
+	GSList *list;
+
+	DBG("%s", modem->syspath);
+
+	for (list = modem->devices; list; list = g_slist_next(list)) {
+		struct device_info *info = list->data;
+
+		DBG("%s %s %s %s %s", info->devnode, info->interface,
+				info->number, info->label, info->subsystem);
+
+		if (g_strcmp0(info->interface, "255/255/255") == 0 &&
+				g_strcmp0(info->number, "03") == 0) {
+			if (g_strcmp0(info->subsystem, "net") == 0)
+				net = info->devnode;
+			else if (g_strcmp0(info->subsystem, "usbmisc") == 0)
+				qmi = info->devnode;
+		}
+	}
+

plugins/udevng.c static gboolean setup_ublox(struct modem_info *modem) · line 1227

Quoted 10 lines
plugins/udevng.c +10 -0
+	DBG("qmi=%s net=%s", qmi, net);
+
+	if (qmi == NULL || net == NULL)
+		return FALSE;
+
+	DBG("qmi=%s net=%s", qmi, net);
+
+	ofono_modem_set_string(modem->modem, "Device", qmi);
+	ofono_modem_set_string(modem->modem, "NetworkInterface", net);
+    ofono_modem_set_string(modem->modem, "Quirk", "SARAR4");

Here

Quoted 13 lines
plugins/udevng.c +9 -0
+
+
+	DBG("gps=%s aux=%s", gps, aux);
+
+	ofono_modem_set_driver(modem->modem, "gobi");
+
+	return TRUE;
+}
+
 static gboolean setup_gemalto(struct modem_info* modem)
 {
 	const char *app = NULL, *gps = NULL, *mdm = NULL,

plugins/udevng.c static struct { · line 1484

Quoted 4 lines
plugins/udevng.c +1 -0
@@ -1441,6 +1481,7 @@ static struct {
 	{ "quectel",	setup_quectel	},
 	{ "quectelqmi",	setup_quectelqmi},
 	{ "ublox",	setup_ublox	},
+    { "ubloxqmi",   setup_ubloxqmi  },

Here

plugins/udevng.c static struct { · line 1894

Quoted 8 lines
plugins/udevng.c +1 -0
 	{ "gemalto",	setup_gemalto	},
 	{ "xmm7xxx",	setup_xmm7xxx	},
 	{ "mbim",	setup_mbim	},
@@ -1850,6 +1891,7 @@ static struct {
 	{ "ublox",	"cdc_ncm",	"1546", "110a"	},
 	{ "ublox",	"rndis_host",	"1546", "1146"	},
 	{ "ublox",	"cdc_acm",	"1546", "1146"	},
+    { "ubloxqmi",   "qmi_wwan", "05c6", "90b2"  },

Here

Quoted 3 lines
plugins/udevng.c +0 -0
 	{ "gemalto",	"option",	"1e2d",	"0053"	},
 	{ "gemalto",	"cdc_wdm",	"1e2d",	"0053"	},
 	{ "gemalto",	"qmi_wwan",	"1e2d",	"0053"	},
#11 lore raw
In reply to Bing Jupiter

Hi Denis,

If we're going to get anywhere with this, the onus probably falls on you to do some cleanup work on these patches. I'll write some comments on the patches and maybe you can munge those into the commit messages...?

Bing Jupiter has been running this modem (uBlox SARA R4) for well over a year with these patches so they are somewhat tested. That said, this modem isn't without issues, but it appears to me that those are mostly firmware related at this point. Yeah, not great advertising for the product; probably best to stay away from it altogether, really...

/Jonas

Quoted 14 lines · Bing Jupiter

Cleaned up comments and resubmit

Bing Jupiter (4):
Detect SARA R4 QMI device
Detect SARA R4 QMI device
Detect SARA R4 QMI device
Detect SARA R4 QMI device

  drivers/atmodem/vendor.h |  1 +
  drivers/qmimodem/gprs.c  | 10 ++++++++++
  plugins/gobi.c           | 11 ++++++++++-
  plugins/udevng.c         | 42 ++++++++++++++++++++++++++++++++++++++++
  4 files changed, 63 insertions(+), 1 deletion(-)
#3 lore raw

Re: [PATCH v5 1/4] Detect SARA R4 QMI device

In reply to Bing Jupiter

Hi Denis,

On 12/05/2021 09:40, Bing Jupiter wrote:

A comment along these lines might be appropriate:

Unlike other uBlox, the SARA R4 is actually a Qualcomm part and supports the QMI protocol mostly as implemented in ofono. The AT command set for this modem does not correspond to that used by other uBlox modems; furthermore, it is quirky to a degree that it doesn't really play well with ofono.

This patch adds support for the uBlox SARA R4 modem as a QMI device.

/Jonas

Quoted 72 lines
---
  plugins/udevng.c | 42 ++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 42 insertions(+)
plugins/udevng.c +42 -0
index 34ac1cc0..46bf5532 100644
@@ -1194,6 +1194,46 @@ static gboolean setup_ublox(struct modem_info *modem)
  	return TRUE;
  }
 
+static gboolean setup_ubloxqmi(struct modem_info *modem) {
+	const char *qmi = NULL, *net = NULL, *gps = NULL, *aux = NULL;
+	GSList *list;
+
+	DBG("%s", modem->syspath);
+
+	for (list = modem->devices; list; list = g_slist_next(list)) {
+		struct device_info *info = list->data;
+
+		DBG("%s %s %s %s %s", info->devnode, info->interface,
+				info->number, info->label, info->subsystem);
+
+		if (g_strcmp0(info->interface, "255/255/255") == 0 &&
+				g_strcmp0(info->number, "03") == 0) {
+			if (g_strcmp0(info->subsystem, "net") == 0)
+				net = info->devnode;
+			else if (g_strcmp0(info->subsystem, "usbmisc") == 0)
+				qmi = info->devnode;
+		}
+	}
+
+	DBG("qmi=%s net=%s", qmi, net);
+
+	if (qmi == NULL || net == NULL)
+		return FALSE;
+
+	DBG("qmi=%s net=%s", qmi, net);
+
+	ofono_modem_set_string(modem->modem, "Device", qmi);
+	ofono_modem_set_string(modem->modem, "NetworkInterface", net);
+    ofono_modem_set_string(modem->modem, "Quirk", "SARAR4");
+
+
+	DBG("gps=%s aux=%s", gps, aux);
+
+	ofono_modem_set_driver(modem->modem, "gobi");
+
+	return TRUE;
+}
+
  static gboolean setup_gemalto(struct modem_info* modem)
  {
  	const char *app = NULL, *gps = NULL, *mdm = NULL,
@@ -1441,6 +1481,7 @@ static struct {
  	{ "quectel",	setup_quectel	},
  	{ "quectelqmi",	setup_quectelqmi},
  	{ "ublox",	setup_ublox	},
+    { "ubloxqmi",   setup_ubloxqmi  },
  	{ "gemalto",	setup_gemalto	},
  	{ "xmm7xxx",	setup_xmm7xxx	},
  	{ "mbim",	setup_mbim	},
@@ -1850,6 +1891,7 @@ static struct {
  	{ "ublox",	"cdc_ncm",	"1546", "110a"	},
  	{ "ublox",	"rndis_host",	"1546", "1146"	},
  	{ "ublox",	"cdc_acm",	"1546", "1146"	},
+    { "ubloxqmi",   "qmi_wwan", "05c6", "90b2"  },
  	{ "gemalto",	"option",	"1e2d",	"0053"	},
  	{ "gemalto",	"cdc_wdm",	"1e2d",	"0053"	},
  	{ "gemalto",	"qmi_wwan",	"1e2d",	"0053"	},
#5 lore raw

Re: [PATCH v5 2/4] Detect SARA R4 QMI device

In reply to Bing Jupiter

Add vendor tag for uBlox SARA R4 modems.

This device is actually a Qualcomm part so it doesn't fall under the uBlox category of devices, at all.

/Jonas

Quoted 17 lines · Bing Jupiter
---
  drivers/atmodem/vendor.h | 1 +
  1 file changed, 1 insertion(+)
drivers/atmodem/vendor.h +1 -0
index 82284e44..38613679 100644
@@ -48,6 +48,7 @@ enum ofono_vendor {
  	OFONO_VENDOR_QUECTEL_EC2X,
  	OFONO_VENDOR_QUECTEL_SERIAL,
  	OFONO_VENDOR_UBLOX,
+    OFONO_VENDOR_UBLOX_SARA_R4,
  	OFONO_VENDOR_XMM,
  	OFONO_VENDOR_GEMALTO,
  };
#7 lore raw

Re: [PATCH v5 3/4] Detect SARA R4 QMI device

In reply to Bing Jupiter

The SARA R4 modem detaches permanently from the network when the NAS Detach action is called. This is problematic because ofono calls Detach when network connectivity is temporarily lost resulting in the modem never attempting to reattach again when the network once again becomes available.

In testing it was discovered, that the call to Attach doesn't appear to be required either.

This patch adds a quirk to the QMI GPRS atom to not call the NAS attach/detach actions for the uBlox SARA R4 device.

This has been tested on several SARA R4 devices that are running in long-term connectivity tests. With this patch, the modem reconnects as the network comes and goes; without the patch, the modem goes idle the first time network connectivity is lost.

/Jonas

Quoted 47 lines · Bing Jupiter
---
  drivers/qmimodem/gprs.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/qmimodem/gprs.c +10 -0
index 896a9e4c..fa20b809 100644
@@ -26,6 +26,7 @@
  #include <ofono/log.h>
  #include <ofono/modem.h>
  #include <ofono/gprs.h>
+#include <drivers/atmodem/vendor.h>
 
  #include "qmi.h"
  #include "nas.h"
@@ -35,6 +36,7 @@
  #include "qmimodem.h"
 
  struct gprs_data {
+    unsigned int vendor;
  	struct qmi_device *dev;
  	struct qmi_service *nas;
  	struct qmi_service *wds;
@@ -284,6 +286,13 @@ static void qmi_set_attached(struct ofono_gprs *gprs, int attached,
 
  	DBG("attached %d", attached);
 
+    if (data->vendor == OFONO_VENDOR_UBLOX_SARA_R4) {
+	    DBG("Debug vendor = OFONO_VENDOR_UBLOX_SARA_R4");
+        CALLBACK_WITH_SUCCESS(cb, cbd->data);
+        g_free(cbd);
+        return;
+    }
+
  	if (attached)
  		action = QMI_NAS_ATTACH_ACTION_ATTACH;
  	else
@@ -406,6 +415,7 @@ static int qmi_gprs_probe(struct ofono_gprs *gprs,
  	DBG("");
 
  	data = g_new0(struct gprs_data, 1);
+    data->vendor = vendor;
 
  	ofono_gprs_set_data(gprs, data);
 
#9 lore raw

Re: [PATCH v5 4/4] Detect SARA R4 QMI device

In reply to Bing Jupiter

Hi Denis,

This patch is fine, with one little fix below.

Patch message:

All QMI devices are currently piggy-backing on the 'gobi' driver to set up the QMI atoms. For the SARA R4, this works with the addition of a quirk.

This patch adds the handling of a SARA R4 quirk to the 'gobi' driver.

Quoted 17 lines · Bing Jupiter
---
  plugins/gobi.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
plugins/gobi.c +1 -0
index 9b5d7cff..5472dd83 100644
@@ -47,6 +47,7 @@
  #include <ofono/location-reporting.h>
  #include <ofono/log.h>
  #include <ofono/message-waiting.h>
+#include <drivers/atmodem/vendor.h>
 
  #include <drivers/qmimodem/qmi.h>
  #include <drivers/qmimodem/dms.h>

plugins/gobi.c static void gobi_post_online(struct ofono_modem *modem) · line 506

Quoted 10 lines
plugins/gobi.c +4 -0
@@ -496,9 +497,17 @@ static void gobi_post_online(struct ofono_modem *modem)
  	struct gobi_data *data = ofono_modem_get_data(modem);
  	struct ofono_gprs *gprs;
  	struct ofono_gprs_context *gc;
+    const char* quirk;
+    unsigned int vendor = 0;
 
  	DBG("%p", modem);
 
+    quirk = ofono_modem_get_string(modem, "Quirk");
+    if (quirk) {

Probably should have done:

if (quirk && !strcmp(quirk, "SARAR4")) {

/Jonas

Quoted 17 lines
plugins/gobi.c +5 -1
+	    DBG("Debug: vendor = OFONO_VENDOR_UBLOX_SARA_R4");
+        vendor = OFONO_VENDOR_UBLOX_SARA_R4;
+    }
+
  	if (data->features & GOBI_NAS) {
  		ofono_netreg_create(modem, 0, "qmimodem", data->device);
  		ofono_netmon_create(modem, 0, "qmimodem", data->device);
@@ -508,7 +517,7 @@ static void gobi_post_online(struct ofono_modem *modem)
  		ofono_ussd_create(modem, 0, "qmimodem", data->device);
 
  	if (data->features & GOBI_WDS) {
-		gprs = ofono_gprs_create(modem, 0, "qmimodem", data->device);
+		gprs = ofono_gprs_create(modem, vendor, "qmimodem", data->device);
  		gc = ofono_gprs_context_create(modem, 0, "qmimodem",
  							data->device);
 
#12 lore raw
In reply to Jonas Bonn

Hi Jonas,

Quoted 5 lines · Jonas Bonn

Hi Denis,

If we're going to get anywhere with this, the onus probably falls on you to do some cleanup work on these patches.  I'll write some comments on the patches and maybe you can munge those into the commit messages...?

What now? ;)

Anyway, I am not taking this set since all patches seem to be whitespace damaged and this needs cleanup anyway.

Quoted 6 lines

Bing Jupiter has been running this modem (uBlox SARA R4) for well over a year with these patches so they are somewhat tested.  That said, this modem isn't without issues, but it appears to me that those are mostly firmware related at this point.  Yeah, not great advertising for the product; probably best to stay away from it altogether, really...

This is driver code, so unless there's something obviously wrong I'm fine taking it. But it should at least comply with doc/coding-style.txt and someone should have ran checkpatch.pl against it to check for issues.

Given that a v6 is needed, do you want to work with Jupiter to make the editorial changes to the commit descriptions?

Regards,
-Denis

author
#10 lore raw

Re: [PATCH v5 4/4] Detect SARA R4 QMI device

In reply to Jonas Bonn

Hi Denis,

Any chance that patch can be processed?

Thank you very much.

Kind regards,

Jupiter

Quoted 9 lines · Jonas Bonn

Hi Denis,

This patch is fine, with one little fix below.

Patch message:

All QMI devices are currently piggy-backing on the 'gobi' driver to set up the QMI atoms. For the SARA R4, this works with the addition of a quirk.