Skip to contentSkip to conversation

oFono uBlox SARA R4 QMI

PATCH In review Bing Jupiter 2 participants 7 messages Feb 24, 2021

lore
Share & tools
lore
#0 lore raw

v2 cover oFono uBlox SARA R4 QMI

Hi Denis,

Hope it can be accepted.

Thank you.

Kind regards,

- Jupiter

Bing Jupiter (4):
SARA R4 QMI support
Enable SARA R4 vendor ID for gprs create
Add SARA R4 vendor ID
Make SARA R4 vendor ID conditional being attach and detach

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

PATCH v2 1/4 SARA R4 QMI support

---
 plugins/udevng.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
plugins/udevng.c +41 -0
index 34ac1cc0..9941145f 100644
@@ -1194,6 +1194,45 @@ 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 +1480,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 +1890,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
#2 lore raw

Re: [PATCH v2 1/4] SARA R4 QMI support

Hi Jupiter,

Please add a description to your patch. Something along these lines:

This adds support for the uBlox SARA-R4 modem.

Unlike other uBlox devices, this modem is actually a Qualcomm part and therefore supports the QMI protocol. For that reason, this doesn't just jack into the usual uBlox modem framework.

The modem has a quirk in that it fails to reconnect to the network if a NAS detach is issued when connectivity is lost; therefore, we need to add some 'vendor' handling to the QMI gprs atom to account for this.

This has been tested... how?

Hope that helps,
Jonas

Quoted 71 lines · Bing Jupiter
---
  plugins/udevng.c | 41 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 41 insertions(+)
plugins/udevng.c +41 -0
index 34ac1cc0..9941145f 100644
@@ -1194,6 +1194,45 @@ 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 +1480,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 +1890,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"	},
#3 lore raw

PATCH v2 2/4 Enable SARA R4 vendor ID for gprs create

In reply to Bing Jupiter
---
 plugins/gobi.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
plugins/gobi.c +10 -1
index 9b5d7cff..3ca739d6 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
#4 lore raw

PATCH v2 3/4 Add SARA R4 vendor ID

In reply to Bing Jupiter
---
 drivers/atmodem/vendor.h | 1 +
 1 file changed, 1 insertion(+)
drivers/atmodem/vendor.h +1 -0
index 82284e44..db9fa263 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
#5 lore raw

PATCH v2 4/4 Make SARA R4 vendor ID conditional being attach and detach

In reply to Bing Jupiter
---
 drivers/qmimodem/gprs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/qmimodem/gprs.c +15 -0
index 896a9e4c..90203dd3 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,18 @@ static void qmi_set_attached(struct ofono_gprs *gprs, int attached,
 
 	DBG("attached %d", attached);
 
+	if (data->vendor == OFONO_VENDOR_UBLOX_SARA_R4) {
+	/* This assumes neither 'attach' nor 'detach' are
+	 * necessary... if 'attach' is required, then you'll
+	 * need to make this section conditional on the action
+	 * being 'detach'
+	 */
+		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 +420,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
#6 lore raw

Re: [PATCH v2 4/4] Make SARA R4 vendor ID conditional being attach and detach

Hi,

Quoted 25 lines · Bing Jupiter
---
  drivers/qmimodem/gprs.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
drivers/qmimodem/gprs.c +2 -0
index 896a9e4c..90203dd3 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;

drivers/qmimodem/gprs.c static void qmi_set_attached(struct ofono_gprs *gprs, int attached, · line 294

Quoted 9 lines
drivers/qmimodem/gprs.c +6 -0
@@ -284,6 +286,18 @@ static void qmi_set_attached(struct ofono_gprs *gprs, int attached,
 
  	DBG("attached %d", attached);
 
+	if (data->vendor == OFONO_VENDOR_UBLOX_SARA_R4) {
+	/* This assumes neither 'attach' nor 'detach' are
+	 * necessary... if 'attach' is required, then you'll
+	 * need to make this section conditional on the action
+	 * being 'detach'
+	 */

Assuming you've tested this, you'll know whether 'attach' is required or not. As such, fix accordingly and remove the above comment.

/Jonas

Quoted 18 lines
drivers/qmimodem/gprs.c +7 -0
+		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 +420,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);