All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/6] ublox: add device flags
@ 2019-03-13 21:35 Jonas Bonn
  2019-03-13 21:35 ` [PATCH v4 2/6] ublox: add TOBY L4 models Jonas Bonn
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Jonas Bonn @ 2019-03-13 21:35 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2792 bytes --]

Some aspects of a device are detectable at runtime, like the USB profile
detection that was added in a patch preceding this one.  This patch
switches the driver over from creating a new "vendor id" for each
profile to just setting a flag.  This is more easily extensible as we
detect other features of the modem.
---
 plugins/ublox.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index 1a412def..d99f5c45 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -49,20 +49,17 @@
 static const char *uusbconf_prefix[] = { "+UUSBCONF:", NULL };
 static const char *none_prefix[] = { NULL };
 
-enum supported_models {
-	SARA_G270			= 1102,
-	TOBYL2_COMPATIBLE_MODE		= 1141,
-	TOBYL2_MEDIUM_THROUGHPUT_MODE	= 1143,
-	TOBYL2_HIGH_THROUGHPUT_MODE	= 1146,
+enum ublox_device_flags {
+	UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE	= (1 << 0),
 };
 
 struct ublox_data {
 	GAtChat *modem;
 	GAtChat *aux;
-	int model_id;
 	enum ofono_vendor vendor_family;
 
 	const struct ublox_model *model;
+	int flags;
 };
 
 static void ublox_debug(const char *str, void *user_data)
@@ -148,7 +145,7 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 		return;
 	}
 
-	if (data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE)
+	if (data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE)
 		/* use bridged mode until routed mode support is added */
 		g_at_chat_send(data->aux, "AT+UBMCONF=2", none_prefix,
 						NULL, NULL, NULL);
@@ -183,13 +180,12 @@ retry:
 	switch (profile) {
 	case 0: /* Fairly back compatible */
 	case 1: /* Fairly back compatible plus audio */
-		data->model_id =  TOBYL2_COMPATIBLE_MODE;
 		break;
 	case 2: /* Low/medium throughput */
-		data->model_id = TOBYL2_MEDIUM_THROUGHPUT_MODE;
-		break;
+		ofono_error("Medium throughput mode not supported");
+		goto error;
 	case 3: /* High throughput mode */
-		data->model_id = TOBYL2_HIGH_THROUGHPUT_MODE;
+		data->flags |= UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE;
 		break;
 	default:
 		ofono_error("Unexpected USB profile: %d", profile);
@@ -390,10 +386,10 @@ static void ublox_post_sim(struct ofono_modem *modem)
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
 	GAtChat *chat = data->modem ? data->modem : data->aux;
-	const char *driver = data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE ?
+	const char *driver = data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE ?
 						"ubloxmodem" : "atmodem";
 	/* Toby L2: Create same number of contexts as supported PDP contexts. */
-	int ncontexts = data->model_id == TOBYL2_HIGH_THROUGHPUT_MODE ? 8 : 1;
+	int ncontexts = data->flags & UBLOX_DEVICE_F_HIGH_THROUGHPUT_MODE ? 8 : 1;
 
 	DBG("%p", modem);
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 2/6] ublox: add TOBY L4 models
  2019-03-13 21:35 [PATCH v4 1/6] ublox: add device flags Jonas Bonn
@ 2019-03-13 21:35 ` Jonas Bonn
  2019-03-13 21:35 ` [PATCH v4 3/6] udevng: detect ublox TOBY L4 Jonas Bonn
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jonas Bonn @ 2019-03-13 21:35 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1878 bytes --]

---
 drivers/ubloxmodem/ubloxmodem.c | 23 +++++++++++++++++++++++
 drivers/ubloxmodem/ubloxmodem.h |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/drivers/ubloxmodem/ubloxmodem.c b/drivers/ubloxmodem/ubloxmodem.c
index 0630fcdf..9e0781f0 100644
--- a/drivers/ubloxmodem/ubloxmodem.c
+++ b/drivers/ubloxmodem/ubloxmodem.c
@@ -60,6 +60,23 @@ const struct ublox_model ublox_models[] = {
 		.name = "TOBY-L280",
 		.flags = UBLOX_F_TOBY_L2|UBLOX_F_HAVE_USBCONF,
 	},
+	/* TOBY L4 series */
+	{
+		.name = "TOBY-L4006",
+		.flags = UBLOX_F_TOBY_L4,
+	},
+	{
+		.name = "TOBY-L4106",
+		.flags = UBLOX_F_TOBY_L4,
+	},
+	{
+		.name = "TOBY-L4206",
+		.flags = UBLOX_F_TOBY_L4,
+	},
+	{
+		.name = "TOBY-L4906",
+		.flags = UBLOX_F_TOBY_L4,
+	},
 	{ /* sentinel */ },
 };
 
@@ -90,6 +107,12 @@ int ublox_is_toby_l2(const struct ublox_model *model)
 	return model->flags & UBLOX_F_TOBY_L2;
 }
 
+int ublox_is_toby_l4(const struct ublox_model *model)
+{
+	return model->flags & UBLOX_F_TOBY_L4;
+}
+
+
 static int ubloxmodem_init(void)
 {
 	ublox_gprs_context_init();
diff --git a/drivers/ubloxmodem/ubloxmodem.h b/drivers/ubloxmodem/ubloxmodem.h
index 1f5b6493..2c5b7433 100644
--- a/drivers/ubloxmodem/ubloxmodem.h
+++ b/drivers/ubloxmodem/ubloxmodem.h
@@ -25,6 +25,7 @@
 
 enum ublox_flags {
 	UBLOX_F_TOBY_L2		= (1 << 0),
+	UBLOX_F_TOBY_L4		= (1 << 1),
 	UBLOX_F_HAVE_USBCONF	= (1 << 2),
 };
 
@@ -37,6 +38,7 @@ const struct ublox_model *ublox_model_from_name(const char *name);
 const struct ublox_model *ublox_model_from_id(int id);
 int ublox_model_to_id(const struct ublox_model *model);
 int ublox_is_toby_l2(const struct ublox_model *model);
+int ublox_is_toby_l4(const struct ublox_model *model);
 
 extern void ublox_gprs_context_init(void);
 extern void ublox_gprs_context_exit(void);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 3/6] udevng: detect ublox TOBY L4
  2019-03-13 21:35 [PATCH v4 1/6] ublox: add device flags Jonas Bonn
  2019-03-13 21:35 ` [PATCH v4 2/6] ublox: add TOBY L4 models Jonas Bonn
@ 2019-03-13 21:35 ` Jonas Bonn
  2019-03-13 21:35 ` [PATCH v4 4/6] Separate ATE and AT+CMEE commands Jonas Bonn
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Jonas Bonn @ 2019-03-13 21:35 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1639 bytes --]

ttyACM0 (USB interface 02) is reportedly unreliable (breaking DHCP setup)
so the recommended approach is to use ttyACM2 (USB interface 06)
exclusively.
---
 plugins/udevng.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/plugins/udevng.c b/plugins/udevng.c
index 4473c0a6..f689b756 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -1090,11 +1090,17 @@ static gboolean setup_ublox(struct modem_info *modem)
 		 *  - high throughput profile : 224/1/3
 		 */
 		} else if (g_strcmp0(info->interface, "2/2/1") == 0) {
-			if (g_strcmp0(info->number, "02") == 0)
-				aux = info->devnode;
-			else if (g_strcmp0(info->number, "00") == 0)
+			if (!g_strcmp0(modem->model, "1010")) {
+				if (g_strcmp0(info->number, "06") == 0)
+					aux = info->devnode;
+			} else {
+				if (g_strcmp0(info->number, "02") == 0)
+					aux = info->devnode;
+			}
+			if (g_strcmp0(info->number, "00") == 0)
 				mdm = info->devnode;
 		} else if (g_strcmp0(info->interface, "2/6/0") == 0 ||
+				g_strcmp0(info->interface, "2/13/0") == 0 ||
 				g_strcmp0(info->interface, "10/0/0") == 0 ||
 				g_strcmp0(info->interface, "224/1/3") == 0) {
 			net = info->devnode;
@@ -1691,6 +1697,8 @@ static struct {
 	{ "quectelqmi",	"qcserial",	"2c7c", "0121"	},
 	{ "quectelqmi",	"qmi_wwan",	"2c7c", "0125"	},
 	{ "quectelqmi",	"qcserial",	"2c7c", "0125"	},
+	{ "ublox",	"cdc_acm",	"1546", "1010"	},
+	{ "ublox",	"cdc_ncm",	"1546", "1010"	},
 	{ "ublox",	"cdc_acm",	"1546", "1102"	},
 	{ "ublox",	"rndis_host",	"1546", "1146"	},
 	{ "ublox",	"cdc_acm",	"1546", "1146"	},
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 4/6] Separate ATE and AT+CMEE commands
  2019-03-13 21:35 [PATCH v4 1/6] ublox: add device flags Jonas Bonn
  2019-03-13 21:35 ` [PATCH v4 2/6] ublox: add TOBY L4 models Jonas Bonn
  2019-03-13 21:35 ` [PATCH v4 3/6] udevng: detect ublox TOBY L4 Jonas Bonn
@ 2019-03-13 21:35 ` Jonas Bonn
  2019-03-13 21:36 ` [PATCH v4 5/6] ublox: extend LTE driver Jonas Bonn
  2019-03-13 21:36 ` [PATCH v4 6/6] ublox: pass model id to LTE plugin Jonas Bonn
  4 siblings, 0 replies; 7+ messages in thread
From: Jonas Bonn @ 2019-03-13 21:35 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 781 bytes --]

The TOBY L4 doesn't seem to like seeing these two commands on the same
line...
---
 plugins/ublox.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index d99f5c45..10660ff0 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -282,7 +282,9 @@ static int ublox_enable(struct ofono_modem *modem)
 	/* The modem can take a while to wake up if just powered on. */
 	g_at_chat_set_wakeup_command(data->aux, "AT\r", 1000, 11000);
 
-	g_at_chat_send(data->aux, "ATE0 +CMEE=1", none_prefix,
+	g_at_chat_send(data->aux, "ATE0", none_prefix,
+					NULL, NULL, NULL);
+	g_at_chat_send(data->aux, "AT+CMEE=1", none_prefix,
 					NULL, NULL, NULL);
 
 	if (g_at_chat_send(data->aux, "AT+CGMM", NULL,
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 5/6] ublox: extend LTE driver
  2019-03-13 21:35 [PATCH v4 1/6] ublox: add device flags Jonas Bonn
                   ` (2 preceding siblings ...)
  2019-03-13 21:35 ` [PATCH v4 4/6] Separate ATE and AT+CMEE commands Jonas Bonn
@ 2019-03-13 21:36 ` Jonas Bonn
  2019-03-13 21:58   ` Denis Kenzior
  2019-03-13 21:36 ` [PATCH v4 6/6] ublox: pass model id to LTE plugin Jonas Bonn
  4 siblings, 1 reply; 7+ messages in thread
From: Jonas Bonn @ 2019-03-13 21:36 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 5089 bytes --]

There are a couple of semi-independent changes here:

* use the 'vendor' parameter to pass the modem 'model'
* support TOBY L4 modem which uses a fixed CID for configuring the EPS
default bearer
* add the setup of authentication parameters that was recently added to
the atmodem LTE driver
---
 drivers/ubloxmodem/lte.c | 101 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 89 insertions(+), 12 deletions(-)

diff --git a/drivers/ubloxmodem/lte.c b/drivers/ubloxmodem/lte.c
index 34397dfe..eb9062d9 100644
--- a/drivers/ubloxmodem/lte.c
+++ b/drivers/ubloxmodem/lte.c
@@ -39,24 +39,85 @@
 
 #include "ubloxmodem.h"
 
-static const char *ucgdflt_prefix[] = { "+UCGDFLT:", NULL };
+static const char *none_prefix[] = { NULL };
 
 struct lte_driver_data {
 	GAtChat *chat;
+	const struct ublox_model *model;
+	struct ofono_lte_default_attach_info pending_info;
 };
 
-static void ucgdflt_cb(gboolean ok, GAtResult *result, gpointer user_data)
+static void at_lte_set_auth_cb(gboolean ok, GAtResult *result,
+							gpointer user_data)
 {
 	struct cb_data *cbd = user_data;
 	ofono_lte_cb_t cb = cbd->cb;
 	struct ofono_error error;
 
-	DBG("ok %d", ok);
-
 	decode_at_error(&error, g_at_result_final_response(result));
 	cb(&error, cbd->data);
 }
 
+static void at_lte_set_default_attach_info_cb(gboolean ok, GAtResult *result,
+							gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_lte_cb_t cb = cbd->cb;
+	void *data = cbd->data;
+	struct lte_driver_data *ldd = cbd->user;
+	struct ofono_error error;
+	char buf[32 + OFONO_GPRS_MAX_USERNAME_LENGTH +
+					OFONO_GPRS_MAX_PASSWORD_LENGTH  + 1];
+	enum ofono_gprs_auth_method auth_method;
+	int cid;
+
+	if (!ok) {
+		decode_at_error(&error, g_at_result_final_response(result));
+		cb(&error, data);
+		return;
+	}
+
+	if (ublox_is_toby_l2(ldd->model)) {
+		/* If CGDCONT has already been used to set up cid 4 then
+		 * the EPS default bearer will be configured from another
+		 * cid (see documentation for how this is selected).  Avoid
+		 * doing so as this assumes as much...
+		 */
+		cid = 4;
+	} else if (ublox_is_toby_l4(ldd->model)) {
+		cid = 1;
+	} else {
+		ofono_error("Unknown model; "
+			"unable to determine EPS default bearer CID");
+		goto out;
+	}
+
+	auth_method = ldd->pending_info.auth_method;
+
+	/* change the authentication method if the  parameters are invalid */
+	if (!*ldd->pending_info.username || !*ldd->pending_info.password)
+		auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
+
+	/* In contrast to CGAUTH, all four parameters are _required_ here;
+	 * if auth type is NONE then username and password must be set to
+	 * empty strings.
+	 */
+	sprintf(buf, "AT+UAUTHREQ=%d,%d,\"%s\",\"%s\"",
+			cid,
+			at_util_gprs_auth_method_to_auth_prot(auth_method),
+			ldd->pending_info.username,
+			ldd->pending_info.password);
+
+	cbd = cb_data_ref(cbd);
+	if (g_at_chat_send(ldd->chat, buf, none_prefix,
+			at_lte_set_auth_cb, cbd, cb_data_unref) > 0)
+		return;
+
+out:
+	cb_data_unref(cbd);
+	CALLBACK_WITH_FAILURE(cb, data);
+}
+
 static void ublox_lte_set_default_attach_info(const struct ofono_lte *lte,
 			const struct ofono_lte_default_attach_info *info,
 			ofono_lte_cb_t cb, void *data)
@@ -67,17 +128,32 @@ static void ublox_lte_set_default_attach_info(const struct ofono_lte *lte,
 
 	DBG("LTE config with APN: %s", info->apn);
 
-	if (strlen(info->apn) > 0)
-		snprintf(buf, sizeof(buf), "AT+UCGDFLT=0,\"IP\",\"%s\"",
+	cbd->user = ldd;
+	memcpy(&ldd->pending_info, info, sizeof(ldd->pending_info));
+
+	if (ublox_is_toby_l2(ldd->model)) {
+		if (strlen(info->apn) > 0)
+			snprintf(buf, sizeof(buf), "AT+UCGDFLT=0,%s,\"%s\"",
+				at_util_gprs_proto_to_pdp_type(info->proto),
+				info->apn);
+		else
+			snprintf(buf, sizeof(buf), "AT+UCGDFLT=0");
+
+	} else if (ublox_is_toby_l4(ldd->model)) {
+		if (strlen(info->apn) > 0)
+			snprintf(buf, sizeof(buf), "AT+CGDCONT=1,%s,\"%s\"",
+				at_util_gprs_proto_to_pdp_type(info->proto),
 				info->apn);
-	else
-		snprintf(buf, sizeof(buf), "AT+UCGDFLT=0");
+		else
+			snprintf(buf, sizeof(buf), "AT+CGDCONT=1");
+	}
 
-	/* We can't do much in case of failure so don't check response. */
-	if (g_at_chat_send(ldd->chat, buf, ucgdflt_prefix,
-				ucgdflt_cb, cbd, g_free) > 0)
+	if (g_at_chat_send(ldd->chat, buf, none_prefix,
+			at_lte_set_default_attach_info_cb,
+			cbd, cb_data_unref) > 0)
 		return;
 
+	cb_data_unref(cbd);
 	CALLBACK_WITH_FAILURE(cb, data);
 }
 
@@ -91,7 +167,7 @@ static gboolean lte_delayed_register(gpointer user_data)
 }
 
 static int ublox_lte_probe(struct ofono_lte *lte,
-					unsigned int vendor, void *data)
+					unsigned int model_id, void *data)
 {
 	GAtChat *chat = data;
 	struct lte_driver_data *ldd;
@@ -103,6 +179,7 @@ static int ublox_lte_probe(struct ofono_lte *lte,
 		return -ENOMEM;
 
 	ldd->chat = g_at_chat_clone(chat);
+	ldd->model = ublox_model_from_id(model_id);
 
 	ofono_lte_set_data(lte, ldd);
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 6/6] ublox: pass model id to LTE plugin
  2019-03-13 21:35 [PATCH v4 1/6] ublox: add device flags Jonas Bonn
                   ` (3 preceding siblings ...)
  2019-03-13 21:36 ` [PATCH v4 5/6] ublox: extend LTE driver Jonas Bonn
@ 2019-03-13 21:36 ` Jonas Bonn
  4 siblings, 0 replies; 7+ messages in thread
From: Jonas Bonn @ 2019-03-13 21:36 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

---
 plugins/ublox.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/plugins/ublox.c b/plugins/ublox.c
index 10660ff0..1c74fe09 100644
--- a/plugins/ublox.c
+++ b/plugins/ublox.c
@@ -408,7 +408,8 @@ static void ublox_post_sim(struct ofono_modem *modem)
 		--ncontexts;
 	}
 
-	ofono_lte_create(modem, 0, "ubloxmodem", data->aux);
+	ofono_lte_create(modem,
+		ublox_model_to_id(data->model), "ubloxmodem", data->aux);
 }
 
 static void ublox_post_online(struct ofono_modem *modem)
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 5/6] ublox: extend LTE driver
  2019-03-13 21:36 ` [PATCH v4 5/6] ublox: extend LTE driver Jonas Bonn
@ 2019-03-13 21:58   ` Denis Kenzior
  0 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2019-03-13 21:58 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]

On 03/13/2019 04:36 PM, Jonas Bonn wrote:
> There are a couple of semi-independent changes here:
> 
> * use the 'vendor' parameter to pass the modem 'model'
> * support TOBY L4 modem which uses a fixed CID for configuring the EPS
> default bearer
> * add the setup of authentication parameters that was recently added to
> the atmodem LTE driver
> ---
>   drivers/ubloxmodem/lte.c | 101 ++++++++++++++++++++++++++++++++++-----
>   1 file changed, 89 insertions(+), 12 deletions(-)
> 

<snip>

> +
> +	if (ublox_is_toby_l2(ldd->model)) {
> +		/* If CGDCONT has already been used to set up cid 4 then
> +		 * the EPS default bearer will be configured from another
> +		 * cid (see documentation for how this is selected).  Avoid
> +		 * doing so as this assumes as much...
> +		 */
> +		cid = 4;
> +	} else if (ublox_is_toby_l4(ldd->model)) {
> +		cid = 1;
> +	} else {

The fact that this is hardcoded is mind-boggling.  What does +CGDCONT=? 
report for usable contexts?

You might want to explore extending ofono_gprs to take additional hints 
as to which cids are 'off limits'.  E.g. perhaps 
ofono_gprs_set_cid_range needs a companion that would tell it that a 
given cid should not be assigned except for cases where it is used by 
ofono_gprs_cid_activated.

<snip>

> +
> +	/* change the authentication method if the  parameters are invalid */
> +	if (!*ldd->pending_info.username || !*ldd->pending_info.password)
> +		auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
> +

By the way, are there profiles with a valid username but no password? 
The original change & api docs preclude that possibility, but I seem to 
recall this is possible.

Anyhow, the entire series has been applied now.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-03-13 21:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 21:35 [PATCH v4 1/6] ublox: add device flags Jonas Bonn
2019-03-13 21:35 ` [PATCH v4 2/6] ublox: add TOBY L4 models Jonas Bonn
2019-03-13 21:35 ` [PATCH v4 3/6] udevng: detect ublox TOBY L4 Jonas Bonn
2019-03-13 21:35 ` [PATCH v4 4/6] Separate ATE and AT+CMEE commands Jonas Bonn
2019-03-13 21:36 ` [PATCH v4 5/6] ublox: extend LTE driver Jonas Bonn
2019-03-13 21:58   ` Denis Kenzior
2019-03-13 21:36 ` [PATCH v4 6/6] ublox: pass model id to LTE plugin Jonas Bonn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.