[PATCH v2 2/3] plugins: udevng: detect gemalto network interfaces
Some gemalto modems, including ELS81x, may provide more than one USB ethernet interface. Detect and save both network interfaces rather than only the last one. Signed-off-by: Sergey Matyukevich --- plugins/udevng.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/udevng.c b/plugins/udevng.c index 7e6a3ab7..839fabdb 100644 --- a/plugins/udevng.c +++ b/plugins/udevng.c @@ -1162,7 +1162,7 @@ static gboolean setup_ublox(struct modem_info *modem) static gboolean setup_gemalto(struct modem_info* modem) { const char *app = NULL, *gps = NULL, *mdm = NULL, - *net = NULL, *qmi = NULL; + *net = NULL, *qmi = NULL, *net2 = NULL; GSList *list; @@ -1197,9 +1197,14 @@ static gboolean setup_gemalto(struct modem_info* modem) else if (g_strcmp0(info->number, "04") == 0) gps = info->devnode; } + if (g_strcmp0(info->interface, "2/6/0") == 0) { - if (g_strcmp0(info->subsystem, "net") == 0) - net = info->devnode; + if (g_strcmp0(info->subsystem, "net") == 0) { + if (g_strcmp0(info->number, "0a") == 0) + net = info->devnode; + if (g_strcmp0(info->number, "0c") == 0) + net2 = info->devnode; + } } } @@ -1216,6 +1221,9 @@ static gboolean setup_gemalto(struct modem_info* modem) ofono_modem_set_string(modem->modem, "Model", modem->model); ofono_modem_set_string(modem->modem, "NetworkInterface", net); + if (net2) + ofono_modem_set_string(modem->modem, "NetworkInterface2", net2); + return TRUE; } -- 2.28.0 ___ ofono mailing list -- ofono@ofono.org To unsubscribe send an email to ofono-le...@ofono.org
[PATCH v2 0/3] gemalto: USB ethernet data path for ELS81x
Hi Denis and all, This patch series enables USB ethernet data path for gemalto modems that support this feature, in particular for ELS81x devices. Regards, Sergey v1 -> v2 - replace g_try_new0 by use g_new0 - drop patch with incorrect fix for modem init Sergey Matyukevich (3): drivers: gemalto: add gprs-context driver plugins: udevng: detect gemalto network interfaces plugins: gemalto: alternative gprs-context driver Makefile.am | 3 +- drivers/gemaltomodem/gemaltomodem.c | 4 +- drivers/gemaltomodem/gemaltomodem.h | 3 + drivers/gemaltomodem/gprs-context.c | 278 plugins/gemalto.c | 12 +- plugins/udevng.c| 14 +- 6 files changed, 308 insertions(+), 6 deletions(-) create mode 100644 drivers/gemaltomodem/gprs-context.c -- 2.28.0 ___ ofono mailing list -- ofono@ofono.org To unsubscribe send an email to ofono-le...@ofono.org
[PATCH v2 1/3] drivers: gemalto: add gprs-context driver
Some gemalto modems provide USB ethernet interfaces for data path. Implement gprs-context driver for such modems to send data via USB ethernet rather than fallback to PPP. Signed-off-by: Sergey Matyukevich --- Makefile.am | 3 +- drivers/gemaltomodem/gemaltomodem.c | 4 +- drivers/gemaltomodem/gemaltomodem.h | 3 + drivers/gemaltomodem/gprs-context.c | 278 4 files changed, 286 insertions(+), 2 deletions(-) create mode 100644 drivers/gemaltomodem/gprs-context.c diff --git a/Makefile.am b/Makefile.am index fbb0eff4..67c3bcbf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -482,7 +482,8 @@ builtin_sources += drivers/atmodem/atutil.h \ drivers/gemaltomodem/gemaltomodem.h \ drivers/gemaltomodem/gemaltomodem.c \ drivers/gemaltomodem/location-reporting.c \ - drivers/gemaltomodem/voicecall.c + drivers/gemaltomodem/voicecall.c \ + drivers/gemaltomodem/gprs-context.c builtin_modules += xmm7modem builtin_sources += drivers/atmodem/atutil.h \ diff --git a/drivers/gemaltomodem/gemaltomodem.c b/drivers/gemaltomodem/gemaltomodem.c index 4818ac66..4b20dd1b 100644 --- a/drivers/gemaltomodem/gemaltomodem.c +++ b/drivers/gemaltomodem/gemaltomodem.c @@ -36,6 +36,7 @@ static int gemaltomodem_init(void) { gemalto_location_reporting_init(); + gemalto_gprs_context_init(); gemalto_voicecall_init(); return 0; @@ -43,8 +44,9 @@ static int gemaltomodem_init(void) static void gemaltomodem_exit(void) { - gemalto_voicecall_exit(); gemalto_location_reporting_exit(); + gemalto_gprs_context_exit(); + gemalto_voicecall_exit(); } OFONO_PLUGIN_DEFINE(gemaltomodem, "Gemalto modem driver", VERSION, diff --git a/drivers/gemaltomodem/gemaltomodem.h b/drivers/gemaltomodem/gemaltomodem.h index 27b1460e..dc0d346b 100644 --- a/drivers/gemaltomodem/gemaltomodem.h +++ b/drivers/gemaltomodem/gemaltomodem.h @@ -27,3 +27,6 @@ extern void gemalto_location_reporting_exit(); extern void gemalto_voicecall_init(); extern void gemalto_voicecall_exit(); + +extern void gemalto_gprs_context_init(); +extern void gemalto_gprs_context_exit(); diff --git a/drivers/gemaltomodem/gprs-context.c b/drivers/gemaltomodem/gprs-context.c new file mode 100644 index ..73cf81a8 --- /dev/null +++ b/drivers/gemaltomodem/gprs-context.c @@ -0,0 +1,278 @@ +/* + * + * oFono - Open Source Telephony + * + * Copyright (C) 2020 Sergey Matyukevich. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "gatchat.h" +#include "gatresult.h" +#include "gattty.h" + +#include "gemaltomodem.h" + +static const char *none_prefix[] = { NULL }; + +struct gprs_context_data { + GAtChat *chat; + unsigned int active_context; + ofono_gprs_context_cb_t cb; + void *cb_data; +}; + +static void cgact_enable_cb(gboolean ok, GAtResult *result, + gpointer user_data) +{ + struct ofono_gprs_context *gc = user_data; + struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); + struct ofono_modem *modem; + const char *interface; + char buf[64]; + + DBG("ok %d", ok); + + if (!ok) { + struct ofono_error error; + + gcd->active_context = 0; + + decode_at_error(&error, g_at_result_final_response(result)); + gcd->cb(&error, gcd->cb_data); + + return; + } + + snprintf(buf, sizeof(buf), "AT^SWWAN=1,%u", gcd->active_context); + g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL); + + modem = ofono_gprs_context_get_modem(gc); + interface = ofono_modem_get_string(modem, "NetworkInterface"); + ofono_gprs_context_set_interface(gc, interface); + + /* Use DHCP */ + ofono_gprs_context_set_ipv4_address(gc, NULL, 0); + + CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data); +} + +static void cgdcont_enable_cb(gboolean ok, GAtResult *result, + gpointer user_data) +{ + struct ofono_gprs_context *gc
[PATCH v2 3/3] plugins: gemalto: alternative gprs-context driver
Use alternative gprs context driver for gemalto modems that provide USB ethernet interfaces for data path. Signed-off-by: Sergey Matyukevich --- plugins/gemalto.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/gemalto.c b/plugins/gemalto.c index 13950742..238c7cc4 100644 --- a/plugins/gemalto.c +++ b/plugins/gemalto.c @@ -588,6 +588,8 @@ static void gemalto_post_sim(struct ofono_modem *modem) struct ofono_gprs *gprs; struct ofono_gprs_context *gc; const char *model = ofono_modem_get_string(modem, "Model"); + const char *driver = NULL; + const char *iface = NULL; DBG("%p", modem); @@ -596,7 +598,15 @@ static void gemalto_post_sim(struct ofono_modem *modem) ofono_sms_create(modem, OFONO_VENDOR_GEMALTO, "atmodem", data->app); gprs = ofono_gprs_create(modem, 0, "atmodem", data->app); - gc = ofono_gprs_context_create(modem, 0, "atmodem", data->mdm); + + iface = ofono_modem_get_string(modem, "NetworkInterface"); + if (iface) { + driver = "gemaltomodem"; + } else { + driver = "atmodem"; + } + + gc = ofono_gprs_context_create(modem, 0, driver, data->mdm); if (gprs && gc) ofono_gprs_add_context(gprs, gc); -- 2.28.0 ___ ofono mailing list -- ofono@ofono.org To unsubscribe send an email to ofono-le...@ofono.org
Re: [RFC PATCH 4/4] plugins: gemalto: fix incomplete at-chat shutdown
Hi Martin, Instead of this dance of opening / closing the chat in order to force-cancel the 'AT' command queued in gemalto_enable(), maybe there should be something in GAtChat itself to handle this case. There's also the retry logic used on quectel modems with auto-detection of baud rates: https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/plugins/quectel.c#n1082 Ah right, I completely forgot about g_at_chat_retry that you added for exactly the use case I outlined above. Thanks for the reminder. Maybe we should just add this modem poking logic into drivers/atmodem/atutil.[ch] or something if it will be used across multiple drivers. Regards, -Denis ___ ofono mailing list -- ofono@ofono.org To unsubscribe send an email to ofono-le...@ofono.org
Re: [RFC PATCH 4/4] plugins: gemalto: fix incomplete at-chat shutdown
Hi Denis and Sergey, On 17/08/2020 21.54, Denis Kenzior wrote: diff --git a/plugins/gemalto.c b/plugins/gemalto.c index 238c7cc4..321c8c1b 100644 --- a/plugins/gemalto.c +++ b/plugins/gemalto.c @@ -222,6 +222,8 @@ static void sim_state_cb(gboolean present, gpointer user_data) struct ofono_modem *modem = user_data; struct gemalto_data *data = ofono_modem_get_data(modem); + DBG(""); + at_util_sim_state_query_free(data->sim_state_query); data->sim_state_query = NULL; @@ -241,6 +243,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) struct ofono_modem *modem = user_data; struct gemalto_data *data = ofono_modem_get_data(modem); + DBG(""); + if (!ok) { g_at_chat_unref(data->app); data->app = NULL; @@ -451,6 +455,8 @@ static void gemalto_modem_ready(GAtResult *result, gpointer user_data) data->modem_ready_id = 0; data->trial_cmd_id = 0; + g_at_chat_cancel_all(data->app); + g_at_chat_unregister_all(data->app); These get called automatically on unref below, assuming this is the last (it should be) reference. g_at_chat_unref(data->app); Instead of this dance of opening / closing the chat in order to force-cancel the 'AT' command queued in gemalto_enable(), maybe there should be something in GAtChat itself to handle this case. Either a 'force cancel the top of the queue because I know the modem is broken' or maybe some form of 'send this on the port until it responds properly'. Alternatively, you could simply use GAtIO and a timer to write stuff to the port until it responds and only create the chat at that time. There's already something a bit similar in the form of g_at_chat_set_wakeup_command(). It was used on the old Neo Freerunner modem which would go to 'sleep' after several seconds of inactivity. So the subsequent AT command would get eaten. You basically had to poke it with an empty command, have it timeout / return OK and then you could go on with submitting AT commands again. But I don't think it is a good fit for this particular case. There's also the retry logic used on quectel modems with auto-detection of baud rates: https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/plugins/quectel.c#n1082 // Martin ___ ofono mailing list -- ofono@ofono.org To unsubscribe send an email to ofono-le...@ofono.org