Open Source Telephony
 help / color / mirror / Atom feed
* [PATCHv2 0/7] Resubmitting STE Driver patches.
@ 2010-08-16 13:54 Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 13:54 ` [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (9 more replies)
  0 siblings, 10 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

Resubmitting based on rebase comments from Denis K.
Changes:

o  SIM-ready and Radio-Settings are now split in two parts,
   one patch for driver and one for plugin.
o  Use MBM stk driver implementation (avoid copying code).

o  Updated error handling for Radio Settings.

o  Various Style issues (new line and tabs).

New patch:
o  Added patch for plugins/ste using Socket stream mode for CAIF,
   and adding support for specifying CAIF interface to bind to.


Sjur Brændeland (7):
  stemodem: Add support for STK by including MBM implementation.
  atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling.
  stemodem: Add polling for SIM ready.
  stemodem: Add Radio Settings to STE Modem
  plugins/ste: Add Radio-Settings
  stemodem: Use RTNL for creating CAIF interface
  plugins/ste: Use SOCK_STREAM for CAIF and enable interface
    specification.

 Makefile.am                       |    6 +-
 drivers/atmodem/sim.c             |    9 +-
 drivers/stemodem/gprs-context.c   |   51 +++++--
 drivers/stemodem/radio-settings.c |  225 ++++++++++++++++++++++++++
 drivers/stemodem/rtnl.c           |  318 +++++++++++++++++++++++++++++++++++++
 drivers/stemodem/rtnl.h           |   24 +++
 drivers/stemodem/stemodem.c       |    4 +
 drivers/stemodem/stemodem.h       |    5 +
 plugins/modem.conf                |    5 +
 plugins/modemconf.c               |    1 +
 plugins/ste.c                     |   79 +++++++++-
 11 files changed, 706 insertions(+), 21 deletions(-)
 create mode 100644 drivers/stemodem/radio-settings.c
 create mode 100644 drivers/stemodem/rtnl.c
 create mode 100644 drivers/stemodem/rtnl.h


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

* [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation.
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 13:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 14:01   ` Marcel Holtmann
  2010-08-16 13:54 ` [PATCHv2 2/7] atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

---
Changes:
 o Use MBM stk driver implementation (avoid copying code).
   Note: stemodm.h has to declare the mbm_stk_init/exit functions because
   	 importing mbmdriver causes compile errors due to duplicated
	 declarations.


 drivers/stemodem/stemodem.c |    2 ++
 drivers/stemodem/stemodem.h |    2 ++
 plugins/ste.c               |    2 ++
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/stemodem/stemodem.c b/drivers/stemodem/stemodem.c
index c18a8b5..0ba7878 100644
--- a/drivers/stemodem/stemodem.c
+++ b/drivers/stemodem/stemodem.c
@@ -38,6 +38,7 @@ static int stemodem_init(void)
 {
 	ste_voicecall_init();
 	ste_gprs_context_init();
+	mbm_stk_init();
 
 	return 0;
 }
@@ -46,6 +47,7 @@ static void stemodem_exit(void)
 {
 	ste_voicecall_exit();
 	ste_gprs_context_exit();
+	mbm_stk_exit();
 }
 
 OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
diff --git a/drivers/stemodem/stemodem.h b/drivers/stemodem/stemodem.h
index 267e001..e10abd3 100644
--- a/drivers/stemodem/stemodem.h
+++ b/drivers/stemodem/stemodem.h
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();
 extern void ste_voicecall_init();
 extern void ste_voicecall_exit();
 
+extern void mbm_stk_init();
+extern void mbm_stk_exit();
diff --git a/plugins/ste.c b/plugins/ste.c
index f3ae0b2..9cb49d3 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -54,6 +54,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
+#include <ofono/stk.h>
 #include <drivers/atmodem/vendor.h>
 
 #include <drivers/stemodem/caif_socket.h>
@@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 
 	gprs = ofono_gprs_create(modem,
 			OFONO_VENDOR_STE, "atmodem", data->chat);
+	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
 	gc = ofono_gprs_context_create(modem, 0, "stemodem", data->chat);
 
 	if (gprs && gc)
-- 
1.7.0.4


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

* [PATCHv2 2/7] atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling.
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 13:54 ` [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 13:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 14:03   ` Marcel Holtmann
  2010-08-16 13:54 ` [PATCHv2 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

---
 drivers/atmodem/sim.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index eb40ad7..8e7c403 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -567,10 +567,12 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,
 	decode_at_error(&error, g_at_result_final_response(result));
 
 	/*
-	 * On the MBM modem, AT+CPIN? keeps returning SIM PIN for a moment
-	 * after successful AT+CPIN="..", but sends *EPEV when that changes.
+	 * On the MBM and STE modem, AT+CPIN? keeps returning SIM PIN for a
+	 * moment after successful AT+CPIN="..", but sends *EPEV when that
+	 * changes.
 	 */
-	if (ok && sd->vendor == OFONO_VENDOR_MBM) {
+	if (ok && (sd->vendor == OFONO_VENDOR_MBM ||
+			sd->vendor == OFONO_VENDOR_STE)) {
 		sd->epev_id = g_at_chat_register(sd->chat, "*EPEV",
 							at_epev_notify,
 							FALSE, cbd, g_free);
@@ -817,6 +819,7 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
 	case OFONO_VENDOR_WAVECOM:
 		g_at_chat_add_terminator(sd->chat, "+CPIN:", 6, TRUE);
 		break;
+	case OFONO_VENDOR_STE:
 	case OFONO_VENDOR_MBM:
 		g_at_chat_send(sd->chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
 		break;
-- 
1.6.3.3


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

* [PATCHv2 3/7] stemodem: Add polling for SIM ready.
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 13:54 ` [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 13:54 ` [PATCHv2 2/7] atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 13:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 13:54 ` [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

Interim solution until support for SIM 'ready' notification is supported.
---
Changes:
 o Fixed style issues (tabs and newlines)


 plugins/ste.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 9cb49d3..e1ca06c 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -60,8 +60,13 @@
 #include <drivers/stemodem/caif_socket.h>
 #include <drivers/stemodem/if_caif.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
+
 struct ste_data {
 	GAtChat *chat;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 };
 
 static int ste_probe(struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 
 	g_at_chat_unref(data->chat);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
+
 	g_free(data);
 }
 
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)
 	ofono_info("%s", str);
 }
 
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	/* Modem returns +CME ERROR: 10 if SIM is not ready. */
+	if (!ok && result->final_or_pdu &&
+			!strcmp(result->final_or_pdu, "+CME ERROR: 10") &&
+			data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* Modem returns ERROR if there is no SIM in slot. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
+
+	g_at_chat_send(data->chat, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
+}
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 
 	DBG("");
 
-	if (!ok)
+	if (!ok) {
 		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
 
-	ofono_modem_set_powered(modem, TRUE);
+	init_simpin_check(modem);
 }
 
 static int ste_enable(struct ofono_modem *modem)
@@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(data->chat, ste_debug, NULL);
 
-	g_at_chat_send(data->chat, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+	g_at_chat_send(data->chat, "AT&F E0 V1 X4 &C1 +CMEE=1",
+			NULL, NULL, NULL, NULL);
 	g_at_chat_send(data->chat, "AT+CFUN=1", NULL, cfun_enable, modem, NULL);
 
 	return -EINPROGRESS;
-- 
1.6.3.3


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

* [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (2 preceding siblings ...)
  2010-08-16 13:54 ` [PATCHv2 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 13:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 14:05   ` Marcel Holtmann
  2010-08-16 13:54 ` [PATCHv2 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

---
Changes since last patch set:
o Moved updates to plugins/ste to separate patch.
o Updated error handling.
o Style issues.


 Makefile.am                       |    4 +-
 drivers/stemodem/radio-settings.c |  223 +++++++++++++++++++++++++++++++++++++
 drivers/stemodem/stemodem.c       |    2 +
 drivers/stemodem/stemodem.h       |    2 +
 4 files changed, 230 insertions(+), 1 deletions(-)
 create mode 100644 drivers/stemodem/radio-settings.c

diff --git a/Makefile.am b/Makefile.am
index 2f0b745..3e1efde 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -204,7 +204,9 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/stemodem/voicecall.c \
 			drivers/stemodem/gprs-context.c \
 			drivers/stemodem/caif_socket.h \
-			drivers/stemodem/if_caif.h
+			drivers/stemodem/if_caif.h \
+			drivers/stemodem/radio-settings.c
+
 
 builtin_modules += phonesim
 builtin_sources += plugins/phonesim.c
diff --git a/drivers/stemodem/radio-settings.c b/drivers/stemodem/radio-settings.c
new file mode 100644
index 0000000..0c5b438
--- /dev/null
+++ b/drivers/stemodem/radio-settings.c
@@ -0,0 +1,223 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *  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 <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/radio-settings.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "stemodem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { "+CFUN:", NULL };
+
+struct radio_settings_data {
+	GAtChat *chat;
+};
+
+enum ste_radio_mode {
+	STE_RADIO_OFF = 0,
+	STE_RADIO_ON = 1,
+	STE_RADIO_FLIGHT_MODE = 4,
+	STE_RADIO_GSM_ONLY = 5,
+	STE_RADIO_WCDMA_ONLY = 6
+};
+
+static gboolean ste_mode_to_ofono_mode(enum ste_radio_mode stemode,
+				enum ofono_radio_access_mode *mode)
+{
+	switch (stemode) {
+	case STE_RADIO_ON:
+		*mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		return TRUE;
+	case STE_RADIO_GSM_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		return TRUE;
+	case STE_RADIO_WCDMA_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		return TRUE;
+	default:
+		return FALSE;
+	}
+}
+
+static gboolean ofono_mode_to_ste_mode(enum ofono_radio_access_mode mode,
+				enum ste_radio_mode *stemode)
+{
+	switch (mode) {
+	case OFONO_RADIO_ACCESS_MODE_ANY:
+		*stemode = STE_RADIO_ON;
+		return TRUE;
+	case OFONO_RADIO_ACCESS_MODE_GSM:
+		*stemode = STE_RADIO_GSM_ONLY;
+		return TRUE;
+
+	case OFONO_RADIO_ACCESS_MODE_UMTS:
+		*stemode = STE_RADIO_WCDMA_ONLY;
+		return TRUE;
+	default:
+		return FALSE;
+	}
+}
+
+static void sterat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
+	enum ofono_radio_access_mode mode;
+	GAtResultIter iter;
+	int value;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CFUN:"))
+		goto err;
+
+	if (!g_at_result_iter_next_number(&iter, &value))
+		goto err;
+
+	if (!ste_mode_to_ofono_mode(value, &mode))
+		goto err;
+
+	CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
+
+	return;
+
+err:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void ste_query_rat_mode(struct ofono_radio_settings *rs,
+				ofono_radio_settings_rat_mode_query_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(rsd->chat, "AT+CFUN?", cfun_prefix,
+					sterat_query_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, -1, data);
+		g_free(cbd);
+	}
+}
+
+static void sterat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	CALLBACK_WITH_SUCCESS(cb, cbd->data);
+}
+
+static void ste_set_rat_mode(struct ofono_radio_settings *rs,
+				enum ofono_radio_access_mode mode,
+				ofono_radio_settings_rat_mode_set_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[20];
+	enum ste_radio_mode value;
+
+	if (!ofono_mode_to_ste_mode(mode, &value)) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+		return;
+	}
+
+	snprintf(buf, sizeof(buf), "AT+CFUN=%u", value);
+
+	if (g_at_chat_send(rsd->chat, buf, none_prefix,
+					sterat_modify_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+	}
+}
+
+static int ste_radio_settings_probe(struct ofono_radio_settings *rs,
+					unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct radio_settings_data *rsd;
+	rsd = g_try_new0(struct radio_settings_data, 1);
+	if (!rsd)
+		return -ENOMEM;
+
+	rsd->chat = chat;
+
+	ofono_radio_settings_set_data(rs, rsd);
+	ofono_radio_settings_register(rs);
+
+	return 0;
+}
+
+static void ste_radio_settings_remove(struct ofono_radio_settings *rs)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	ofono_radio_settings_set_data(rs, NULL);
+	g_free(rsd);
+}
+
+static struct ofono_radio_settings_driver driver = {
+	.name			= "stemodem",
+	.probe			= ste_radio_settings_probe,
+	.remove		= ste_radio_settings_remove,
+	.query_rat_mode	= ste_query_rat_mode,
+	.set_rat_mode		= ste_set_rat_mode
+};
+
+void ste_radio_settings_init()
+{
+	ofono_radio_settings_driver_register(&driver);
+}
+
+void ste_radio_settings_exit()
+{
+	ofono_radio_settings_driver_unregister(&driver);
+}
diff --git a/drivers/stemodem/stemodem.c b/drivers/stemodem/stemodem.c
index 0ba7878..15c6c53 100644
--- a/drivers/stemodem/stemodem.c
+++ b/drivers/stemodem/stemodem.c
@@ -39,6 +39,7 @@ static int stemodem_init(void)
 	ste_voicecall_init();
 	ste_gprs_context_init();
 	mbm_stk_init();
+	ste_radio_settings_init();
 
 	return 0;
 }
@@ -48,6 +49,7 @@ static void stemodem_exit(void)
 	ste_voicecall_exit();
 	ste_gprs_context_exit();
 	mbm_stk_exit();
+	ste_radio_settings_exit();
 }
 
 OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,

-- 
1.6.3.3


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

* [PATCHv2 5/7] plugins/ste: Add Radio-Settings
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (3 preceding siblings ...)
  2010-08-16 13:54 ` [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 13:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 13:54 ` [PATCHv2 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

---
 plugins/ste.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index e1ca06c..1e3ed9d 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -55,6 +55,7 @@
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/stk.h>
+#include <ofono/radio-settings.h>
 #include <drivers/atmodem/vendor.h>
 
 #include <drivers/stemodem/caif_socket.h>
@@ -292,6 +293,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 	gprs = ofono_gprs_create(modem,
 			OFONO_VENDOR_STE, "atmodem", data->chat);
 	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->chat);
 	gc = ofono_gprs_context_create(modem, 0, "stemodem", data->chat);
 
 	if (gprs && gc)
-- 
1.6.3.3


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

* [PATCHv2 6/7] stemodem: Use RTNL for creating CAIF interface
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (4 preceding siblings ...)
  2010-08-16 13:54 ` [PATCHv2 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 13:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 13:54 ` [PATCHv2 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

CAIF in Linux kernel 2.6.35 must use RTNL for configuring
CAIF interfaces.
---
 Makefile.am                     |    4 +-
 drivers/stemodem/gprs-context.c |   51 +++++--
 drivers/stemodem/rtnl.c         |  318 +++++++++++++++++++++++++++++++++++++++
 drivers/stemodem/rtnl.h         |   24 +++
 4 files changed, 383 insertions(+), 14 deletions(-)
 create mode 100644 drivers/stemodem/rtnl.c
 create mode 100644 drivers/stemodem/rtnl.h

diff --git a/Makefile.am b/Makefile.am
index 3e1efde..1298fb9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -205,7 +205,9 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/stemodem/gprs-context.c \
 			drivers/stemodem/caif_socket.h \
 			drivers/stemodem/if_caif.h \
-			drivers/stemodem/radio-settings.c
+			drivers/stemodem/radio-settings.c \
+			drivers/stemodem/rtnl.h \
+			drivers/stemodem/rtnl.c
 
 
 builtin_modules += phonesim
diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index ace9d6e..591df33 100644
--- a/drivers/stemodem/gprs-context.c
+++ b/drivers/stemodem/gprs-context.c
@@ -43,8 +43,9 @@
 
 #include "gatchat.h"
 #include "gatresult.h"
+
+#include "rtnl.h"
 #include "stemodem.h"
-#include "caif_socket.h"
 #include "if_caif.h"
 
 #define MAX_CAIF_DEVICES 7
@@ -68,7 +69,8 @@ struct conn_info {
 	unsigned int cid;
 	unsigned int device;
 	unsigned int channel_id;
-	char interface[10];
+	char ifname[16];
+	int ifindex;
 };
 
 struct eppsd_response {
@@ -171,17 +173,40 @@ static struct conn_info *conn_info_create(unsigned int device,
 /*
  * Creates a new IP interface for CAIF.
  */
-static gboolean caif_if_create(const char *interface, unsigned int connid)
+static gboolean caif_if_create(struct conn_info *conn)
 {
-	return FALSE;
+
+	strcpy(conn->ifname, "caif%d");
+	if (rtnl_create_caif_interface(IFLA_CAIF_IPV4_CONNID,
+					conn->channel_id,
+					conn->ifname,
+					&conn->ifindex) < 0) {
+		DBG("Failed to create IP interface for CAIF");
+		return FALSE;
+	}
+
+	DBG("created CAIF interface ch:%d ifname:%s ifindex:%d\n",
+		conn->channel_id, conn->ifname, conn->ifindex);
+
+	return TRUE;
 }
 
 /*
  * Removes IP interface for CAIF.
  */
-static gboolean caif_if_remove(const char *interface, unsigned int connid)
+static gboolean caif_if_remove(struct conn_info *conn)
 {
-	return FALSE;
+
+	if (rtnl_delete_caif_interface(conn->ifindex) < 0) {
+		ofono_error("Failed to delete caif interface %s",
+			conn->ifname);
+		return FALSE;
+	}
+
+	DBG("removed CAIF interface ch:%d ifname:%s ifindex:%d\n",
+		conn->channel_id, conn->ifname, conn->ifindex);
+
+	return TRUE;
 }
 
 static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
@@ -211,9 +236,9 @@ static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
 
 	conn = l->data;
 
-	if (!caif_if_remove(conn->interface, conn->channel_id)) {
+	if (!caif_if_remove(conn)) {
 		DBG("Failed to remove caif interface %s.",
-				conn->interface);
+				conn->ifname);
 	}
 
 	conn->cid = 0;
@@ -283,16 +308,16 @@ static void ste_eppsd_up_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	dns[1] = rsp.dns_server2;
 	dns[2] = NULL;
 
-	sprintf(conn->interface, "caif%u", conn->device);
+	sprintf(conn->ifname, "caif%u", conn->device);
 
-	if (!caif_if_create(conn->interface, conn->channel_id)) {
+	if (!caif_if_create(conn)) {
 		ofono_error("Failed to create caif interface %s.",
-				conn->interface);
+				conn->ifname);
 		CALLBACK_WITH_SUCCESS(cb, NULL, FALSE, rsp.ip_address,
 				rsp.subnet_mask, rsp.default_gateway,
 				dns, cbd->data);
 	} else {
-		CALLBACK_WITH_SUCCESS(cb, conn->interface,
+		CALLBACK_WITH_SUCCESS(cb, conn->ifname,
 				FALSE, rsp.ip_address, rsp.subnet_mask,
 				rsp.default_gateway, dns, cbd->data);
 	}
@@ -544,7 +569,7 @@ static void ste_gprs_context_remove(struct ofono_gprs_context *gc)
 static struct ofono_gprs_context_driver driver = {
 	.name			= "stemodem",
 	.probe			= ste_gprs_context_probe,
-	.remove			= ste_gprs_context_remove,
+	.remove		= ste_gprs_context_remove,
 	.activate_primary	= ste_gprs_activate_primary,
 	.deactivate_primary	= ste_gprs_deactivate_primary,
 };
diff --git a/drivers/stemodem/rtnl.c b/drivers/stemodem/rtnl.c
new file mode 100644
index 0000000..7990810
--- /dev/null
+++ b/drivers/stemodem/rtnl.c
@@ -0,0 +1,318 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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 <config.h>
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <net/if_arp.h>
+#include <linux/rtnetlink.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+
+#include "if_caif.h"
+#include "rtnl.h"
+
+#define NLMSG_TAIL(nmsg) \
+	((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
+
+struct iplink_req {
+	struct nlmsghdr n;
+	struct ifinfomsg i;
+	char pad[1024];
+	int ifindex;
+	char ifname[16];
+	int result;
+};
+
+static guint32 ipconfig_seqnr = 1;
+
+static gboolean get_ifname(struct ifinfomsg *msg, int bytes,
+			const char **ifname)
+{
+	struct rtattr *attr;
+
+	for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
+			attr = RTA_NEXT(attr, bytes))
+
+		if (attr->rta_type == IFLA_IFNAME &&
+				ifname != NULL) {
+			*ifname = RTA_DATA(attr);
+			return TRUE;
+		}
+
+	return FALSE;
+}
+
+static void handle_rtnl_response(struct iplink_req *req, unsigned short type,
+					int index, unsigned flags,
+					unsigned change, struct ifinfomsg *msg,
+					int bytes)
+{
+	const char *ifname = NULL;
+
+	get_ifname(msg, bytes, &ifname);
+	req->ifindex = index;
+	strncpy(req->ifname, ifname,
+			sizeof(req->ifname));
+	req->ifname[sizeof(req->ifname)-1] = '\0';
+}
+
+static int send_iplink_req(int sk, struct iplink_req *req)
+{
+	struct sockaddr_nl addr;
+
+	memset(&addr, 0, sizeof(addr));
+	addr.nl_family = AF_NETLINK;
+
+	return sendto(sk, req, req->n.nlmsg_len, 0,
+			(struct sockaddr *) &addr, sizeof(addr));
+}
+
+static int parse_rtnl_message(void *buf, size_t len, struct iplink_req *req)
+{
+	struct ifinfomsg *msg;
+
+	while (len > 0) {
+		struct nlmsghdr *hdr = buf;
+		struct nlmsgerr *err;
+
+		if (!NLMSG_OK(hdr, len))
+			break;
+
+		if (hdr->nlmsg_type == NLMSG_ERROR) {
+			err = NLMSG_DATA(hdr);
+			DBG("RTNL failed: seq:%d error %d (%s)",
+					hdr->nlmsg_seq, err->error,
+					strerror(-err->error));
+			req->result = err->error;
+			return err->error;
+		}
+
+		else if (hdr->nlmsg_type == RTM_NEWLINK ||
+			hdr->nlmsg_type == RTM_DELLINK) {
+			msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
+			handle_rtnl_response(req, msg->ifi_type,
+					msg->ifi_index, msg->ifi_flags,
+					msg->ifi_change, msg,
+					IFA_PAYLOAD(hdr));
+			break;
+		} else
+			return -1;
+
+		len -= hdr->nlmsg_len;
+		buf += hdr->nlmsg_len;
+	}
+	return 1;
+}
+
+static int netlink_get_response(int sk, struct iplink_req *req)
+{
+	unsigned char buf[4096];
+	int ret;
+
+	memset(buf, 0, sizeof(buf));
+
+	do {
+		ret = read(sk, buf, sizeof(buf));
+		if (ret < 0)
+			break;
+		ret = parse_rtnl_message(buf, sizeof(buf), req);
+	} while (ret > 0);
+
+	return ret;
+}
+
+static int add_attribute(struct nlmsghdr *n, int maxlen, int type,
+			const void *data, int datalen)
+{
+	int len = RTA_LENGTH(datalen);
+	struct rtattr *rta;
+
+	if ((int)(NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) {
+		DBG("attribute to large for message %d %d %d\n",
+				n->nlmsg_len, len, maxlen);
+		return -1;
+	}
+
+	rta = NLMSG_TAIL(n);
+	rta->rta_type = type;
+	rta->rta_len = len;
+	memcpy(RTA_DATA(rta), data, datalen);
+	n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
+
+	return 0;
+}
+
+static int create_caif_interface(int sk, struct iplink_req *req,
+					int connection_type, char *ifname,
+					int nsapi, int loop_enabled)
+{
+	char type[] = "caif";
+	struct rtattr *linkinfo;
+	struct rtattr *data;
+
+	req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+	req->n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL|NLM_F_ACK;
+	req->n.nlmsg_type = RTM_NEWLINK;
+	req->n.nlmsg_seq = ipconfig_seqnr++;
+	req->i.ifi_family = AF_UNSPEC;
+
+	linkinfo = NLMSG_TAIL(&req->n);
+
+	add_attribute(&req->n, sizeof(*req), IFLA_LINKINFO,
+			NULL, 0);
+
+	add_attribute(&req->n, sizeof(*req), IFLA_INFO_KIND,
+			type, strlen(type));
+
+	add_attribute(&req->n, sizeof(*req), IFLA_IFNAME,
+			ifname, strlen(ifname));
+
+	data = NLMSG_TAIL(&req->n);
+	add_attribute(&req->n, sizeof(*req), IFLA_INFO_DATA,
+			NULL, 0);
+
+	if (connection_type == IFLA_CAIF_IPV4_CONNID)
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_IPV4_CONNID, &nsapi, sizeof(nsapi));
+	else if (connection_type == IFLA_CAIF_IPV6_CONNID)
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_IPV6_CONNID, &nsapi, sizeof(nsapi));
+	else {
+		DBG("unsupported linktype\n");
+		g_free(req);
+		return -1;
+	}
+
+	if (loop_enabled) {
+		int loop;
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_LOOPBACK, &loop, sizeof(loop));
+	}
+
+	data->rta_len = (void *)NLMSG_TAIL(&req->n) - (void *)data;
+
+	linkinfo->rta_len = (void *)NLMSG_TAIL(&req->n) - (void *)linkinfo;
+
+	return send_iplink_req(sk, req);
+}
+
+static int destroy_caif_interface(int sk, struct iplink_req *req, int ifindex)
+{
+
+	req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+	req->n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL|NLM_F_ACK;
+	req->n.nlmsg_type = RTM_DELLINK;
+	req->n.nlmsg_seq = ipconfig_seqnr++;
+	req->i.ifi_family = AF_UNSPEC;
+	req->i.ifi_index = ifindex;
+
+	return send_iplink_req(sk, req);
+}
+
+static int rtnl_init(void)
+{
+	struct sockaddr_nl addr;
+	int sk, ret;
+
+	sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
+	if (sk < 0)
+		return sk;
+
+	memset(&addr, 0, sizeof(addr));
+	addr.nl_family = AF_NETLINK;
+	addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE;
+
+	ret = bind(sk, (struct sockaddr *) &addr, sizeof(addr));
+
+	if (ret < 0) {
+		close(sk);
+		return ret;
+	}
+
+	return sk;
+}
+
+/* Note ifname is in/out and must be minimum size 16 */
+int rtnl_create_caif_interface(int type, int conn_id, char ifname[16],
+					int *ifindex)
+{
+	int sk, ret;
+	int loop = 0;
+	struct iplink_req req;
+
+	memset(&req, 0, sizeof(req));
+	*ifindex = -1;
+
+	sk = rtnl_init();
+	ret = sk;
+	if (sk < 0)
+		goto out;
+
+	ret = create_caif_interface(sk, &req, type, ifname, conn_id, loop);
+	if (ret < 0)
+		goto out;
+
+	ret = netlink_get_response(sk, &req);
+	if (ret < 0)
+		goto out;
+
+	strncpy(ifname, req.ifname, sizeof(req.ifname));
+	ifname[sizeof(req.ifname)-1] = '\0';
+	*ifindex = req.ifindex;
+	ret = req.result;
+
+out:
+	close(sk);
+	return ret;
+}
+
+int rtnl_delete_caif_interface(int ifid)
+{
+	struct iplink_req req;
+	int sk, ret;
+
+	memset(&req, 0, sizeof(req));
+
+	sk = rtnl_init();
+	ret = sk;
+	if (sk < 0)
+		goto out;
+
+	ret = destroy_caif_interface(sk, &req, ifid);
+	if (ret < 0)
+		goto out;
+
+	ret = netlink_get_response(sk, &req);
+	if (ret < 0)
+		goto out;
+
+	ret = req.result;
+
+out:
+	close(sk);
+	return ret;
+}
diff --git a/drivers/stemodem/rtnl.h b/drivers/stemodem/rtnl.h
new file mode 100644
index 0000000..8f6a84f
--- /dev/null
+++ b/drivers/stemodem/rtnl.h
@@ -0,0 +1,24 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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
+ *
+ */
+
+extern int rtnl_create_caif_interface(int type, int conn_id, char ifname[16],
+					int *ifindex);
+extern int rtnl_delete_caif_interface(int ifid);
-- 
1.6.3.3


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

* [PATCHv2 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (5 preceding siblings ...)
  2010-08-16 13:54 ` [PATCHv2 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 13:54 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35 ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 13:54 UTC (permalink / raw)
  To: ofono

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

---
 plugins/modem.conf  |    5 +++++
 plugins/modemconf.c |    1 +
 plugins/ste.c       |   20 +++++++++++++++++++-
 3 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/plugins/modem.conf b/plugins/modem.conf
index 66bf932..b577114 100644
--- a/plugins/modem.conf
+++ b/plugins/modem.conf
@@ -44,3 +44,8 @@
 #[n900]
 #Driver=n900modem
 #Interface=phonet0
+
+# Sample STE modem
+#[ste]
+#Interface=cfttyS0
+#Driver=ste
diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 3747cd9..d7b1354 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -138,6 +138,7 @@ static struct {
 	{ "g1",		set_device	},
 	{ "wavecom",	set_device	},
 	{ "ste",	set_device	},
+	{ "ste",	set_interface	},
 	{ "calypso",	set_device	},
 	{ "palmpre",	set_device	},
 	{ "isimodem",	set_interface	},
diff --git a/plugins/ste.c b/plugins/ste.c
index 1e3ed9d..3e227af 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <net/if.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)
 	if (!device) {
 		struct sockaddr_caif addr;
 		int err;
+		const char *interface;
 
 		/* Create a CAIF socket for AT Service */
-		fd = socket(AF_CAIF, SOCK_SEQPACKET, CAIFPROTO_AT);
+		fd = socket(AF_CAIF, SOCK_STREAM, CAIFPROTO_AT);
 		if (fd < 0) {
 			ofono_error("Failed to create CAIF socket for AT");
 			return -EIO;
 		}
 
+		/* Bind CAIF socket to specified interface */
+		interface = ofono_modem_get_string(modem, "Interface");
+		if (interface) {
+			struct ifreq ifreq;
+			memset(&ifreq, 0, sizeof(ifreq));
+			strcpy(ifreq.ifr_name, interface);
+			err = setsockopt(fd, SOL_SOCKET,
+					SO_BINDTODEVICE, &ifreq, sizeof(ifreq));
+			if (err < 0) {
+				ofono_error("Failed to bind caif socket "
+					"to interface");
+				close(fd);
+				return err;
+			}
+		}
+
 		memset(&addr, 0, sizeof(addr));
 		addr.family = AF_CAIF;
 		addr.u.at.type = CAIF_ATTYPE_PLAIN;
-- 
1.6.3.3


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

* Re: [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation.
  2010-08-16 13:54 ` [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 14:01   ` Marcel Holtmann
  2010-08-16 16:21     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  0 siblings, 1 reply; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 14:01 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> Changes:
>  o Use MBM stk driver implementation (avoid copying code).
>    Note: stemodm.h has to declare the mbm_stk_init/exit functions because
>    	 importing mbmdriver causes compile errors due to duplicated
> 	 declarations.
> 
> 
>  drivers/stemodem/stemodem.c |    2 ++
>  drivers/stemodem/stemodem.h |    2 ++
>  plugins/ste.c               |    2 ++
>  3 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/stemodem/stemodem.c b/drivers/stemodem/stemodem.c
> index c18a8b5..0ba7878 100644
> --- a/drivers/stemodem/stemodem.c
> +++ b/drivers/stemodem/stemodem.c
> @@ -38,6 +38,7 @@ static int stemodem_init(void)
>  {
>  	ste_voicecall_init();
>  	ste_gprs_context_init();
> +	mbm_stk_init();
>  
>  	return 0;
>  }
> @@ -46,6 +47,7 @@ static void stemodem_exit(void)
>  {
>  	ste_voicecall_exit();
>  	ste_gprs_context_exit();
> +	mbm_stk_exit();
>  }
>  
>  OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
> diff --git a/drivers/stemodem/stemodem.h b/drivers/stemodem/stemodem.h
> index 267e001..e10abd3 100644
> --- a/drivers/stemodem/stemodem.h
> +++ b/drivers/stemodem/stemodem.h
> @@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();
>  extern void ste_voicecall_init();
>  extern void ste_voicecall_exit();
>  
> +extern void mbm_stk_init();
> +extern void mbm_stk_exit();

all the magic above is not needed. The build system builds the plugins
properly and you can cross reference modem drivers from your modem
plugin without any problems.

> diff --git a/plugins/ste.c b/plugins/ste.c
> index f3ae0b2..9cb49d3 100644
> --- a/plugins/ste.c
> +++ b/plugins/ste.c
> @@ -54,6 +54,7 @@
>  #include <ofono/voicecall.h>
>  #include <ofono/gprs.h>
>  #include <ofono/gprs-context.h>
> +#include <ofono/stk.h>
>  #include <drivers/atmodem/vendor.h>
>  
>  #include <drivers/stemodem/caif_socket.h>
> @@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem)
>  
>  	gprs = ofono_gprs_create(modem,
>  			OFONO_VENDOR_STE, "atmodem", data->chat);
> +	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
>  	gc = ofono_gprs_context_create(modem, 0, "stemodem", data->chat);
>  
>  	if (gprs && gc)

Only these two changes are needed.

Regards

Marcel



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

* Re: [PATCHv2 2/7] atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling.
  2010-08-16 13:54 ` [PATCHv2 2/7] atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 14:03   ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 14:03 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

>  drivers/atmodem/sim.c |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
> index eb40ad7..8e7c403 100644
> --- a/drivers/atmodem/sim.c
> +++ b/drivers/atmodem/sim.c
> @@ -567,10 +567,12 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,
>  	decode_at_error(&error, g_at_result_final_response(result));
>  
>  	/*
> -	 * On the MBM modem, AT+CPIN? keeps returning SIM PIN for a moment
> -	 * after successful AT+CPIN="..", but sends *EPEV when that changes.
> +	 * On the MBM and STE modem, AT+CPIN? keeps returning SIM PIN for a
> +	 * moment after successful AT+CPIN="..", but sends *EPEV when that
> +	 * changes.
>  	 */
> -	if (ok && sd->vendor == OFONO_VENDOR_MBM) {
> +	if (ok && (sd->vendor == OFONO_VENDOR_MBM ||
> +			sd->vendor == OFONO_VENDOR_STE)) {
>  		sd->epev_id = g_at_chat_register(sd->chat, "*EPEV",
>  							at_epev_notify,
>  							FALSE, cbd, g_free);
> @@ -817,6 +819,7 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
>  	case OFONO_VENDOR_WAVECOM:
>  		g_at_chat_add_terminator(sd->chat, "+CPIN:", 6, TRUE);
>  		break;
> +	case OFONO_VENDOR_STE:
>  	case OFONO_VENDOR_MBM:
>  		g_at_chat_send(sd->chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
>  		break;

do we really wanna create another vendor quirk here. If both modems
behave identical then just pass OFONO_VENDOR_MBM in the SIM atom
registration and be done with it.

Regards

Marcel



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

* Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-16 13:54 ` [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 14:05   ` Marcel Holtmann
  2010-08-16 16:29     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  0 siblings, 1 reply; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 14:05 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> Changes since last patch set:
> o Moved updates to plugins/ste to separate patch.
> o Updated error handling.
> o Style issues.
> 
> 
>  Makefile.am                       |    4 +-
>  drivers/stemodem/radio-settings.c |  223 +++++++++++++++++++++++++++++++++++++
>  drivers/stemodem/stemodem.c       |    2 +
>  drivers/stemodem/stemodem.h       |    2 +
>  4 files changed, 230 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/stemodem/radio-settings.c

is this identical to how MBM does it? If yes, then I prefer we add this
to drivers/mbmmodem/ and you just reference it. If not then I like to
see the MBM version of this and where it actually differs. Maybe a MBM
version with a STE quirk is better.

I prefer doing this in MBM since that modem driver was just the first.
There is no other preference here ;)

Regards

Marcel



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

* Re: [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation.
  2010-08-16 14:01   ` Marcel Holtmann
@ 2010-08-16 16:21     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  0 siblings, 0 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 16:21 UTC (permalink / raw)
  To: ofono

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

Marcel Holtmann <marcel@holtmann.org> wrote:
> all the magic above is not needed. The build system builds the plugins
> properly and you can cross reference modem drivers from your modem
> plugin without any problems.

Sure, I'll change this.

Regards
Sjur

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

* Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-16 14:05   ` Marcel Holtmann
@ 2010-08-16 16:29     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 16:36       ` Marcel Holtmann
  0 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 16:29 UTC (permalink / raw)
  To: ofono

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

Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Sjur,
>
>> Changes since last patch set:
>> o Moved updates to plugins/ste to separate patch.
>> o Updated error handling.
>> o Style issues.
>>
>>
>>  Makefile.am                       |    4 +-
>>  drivers/stemodem/radio-settings.c |  223 +++++++++++++++++++++++++++++++++++++
>>  drivers/stemodem/stemodem.c       |    2 +
>>  drivers/stemodem/stemodem.h       |    2 +
>>  4 files changed, 230 insertions(+), 1 deletions(-)
>>  create mode 100644 drivers/stemodem/radio-settings.c
>
> is this identical to how MBM does it? If yes, then I prefer we add this
> to drivers/mbmmodem/ and you just reference it. If not then I like to
> see the MBM version of this and where it actually differs. Maybe a MBM
> version with a STE quirk is better.

Actually this is not yet implemented by MBM, so I guess STE is master
this time ;-)

> I prefer doing this in MBM since that modem driver was just the first.
> There is no other preference here ;)

This actually raises one question. How should we handle version variations from
the same Modem vendor.
The differences will be larger as we start adding support for LTE, and
support different
bearers (PC cards with USB and Modems with CAIF).
Should we create more entries in the vendor enum, or do you have something
else in mind?

Regards
Sjur

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

* Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-16 16:29     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 16:36       ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 16:36 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> >> Changes since last patch set:
> >> o Moved updates to plugins/ste to separate patch.
> >> o Updated error handling.
> >> o Style issues.
> >>
> >>
> >>  Makefile.am                       |    4 +-
> >>  drivers/stemodem/radio-settings.c |  223 +++++++++++++++++++++++++++++++++++++
> >>  drivers/stemodem/stemodem.c       |    2 +
> >>  drivers/stemodem/stemodem.h       |    2 +
> >>  4 files changed, 230 insertions(+), 1 deletions(-)
> >>  create mode 100644 drivers/stemodem/radio-settings.c
> >
> > is this identical to how MBM does it? If yes, then I prefer we add this
> > to drivers/mbmmodem/ and you just reference it. If not then I like to
> > see the MBM version of this and where it actually differs. Maybe a MBM
> > version with a STE quirk is better.
> 
> Actually this is not yet implemented by MBM, so I guess STE is master
> this time ;-)

I thought that part would be similar in both cards. Then I am fine with
this.

> > I prefer doing this in MBM since that modem driver was just the first.
> > There is no other preference here ;)
> 
> This actually raises one question. How should we handle version variations from
> the same Modem vendor.
> The differences will be larger as we start adding support for LTE, and
> support different
> bearers (PC cards with USB and Modems with CAIF).
> Should we create more entries in the vendor enum, or do you have something
> else in mind?

We cross that bridge when we get to it.

Regards

Marcel



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

* [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver.
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (6 preceding siblings ...)
  2010-08-16 13:54 ` [PATCHv2 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:35 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35   ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:44   ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Marcel Holtmann
  2010-08-16 21:12 ` [PATCH v4 " Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  9 siblings, 2 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 20:35 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
Marcel Holtmann wrote:
> ... The build system builds the plugins
> properly and you can cross reference modem drivers from your modem
> plugin without any problems.

Simply refering to MBM driver from ste.c

 plugins/ste.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index f3ae0b2..9cb49d3 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -54,6 +54,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
+#include <ofono/stk.h>
 #include <drivers/atmodem/vendor.h>
 
 #include <drivers/stemodem/caif_socket.h>
@@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 
 	gprs = ofono_gprs_create(modem,
 			OFONO_VENDOR_STE, "atmodem", data->chat);
+	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
 	gc = ofono_gprs_context_create(modem, 0, "stemodem", data->chat);
 
 	if (gprs && gc)
-- 
1.6.3.3


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

* [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
  2010-08-16 20:35 ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:35   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35     ` [PATCH v3 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:45     ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Marcel Holtmann
  2010-08-16 20:44   ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Marcel Holtmann
  1 sibling, 2 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 20:35 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
Marcel Holtmann wrote:
...
>do we really wanna create another vendor quirk here. If both modems
>behave identical then just pass OFONO_VENDOR_MBM in the SIM atom
>registration and be done with it.

Re-use the MBM quirk rather than adding STE quirks in atmodem/sim.c

---
 plugins/ste.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 9cb49d3..9d9afd6 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)
 
 	ofono_devinfo_create(modem, 0, "atmodem", data->chat);
 	sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
-	ofono_voicecall_create(modem, 0, "stemodem", data->chat);
+	ofono_voicecall_create(modem, OFONO_VENDOR_MBM, "stemodem", data->chat);
 
 	if (sim)
 		ofono_sim_inserted_notify(sim, TRUE);
-- 
1.6.3.3


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

* [PATCH v3 3/7] stemodem: Add polling for SIM ready.
  2010-08-16 20:35   ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:35     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35       ` [PATCH v3 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:45     ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Marcel Holtmann
  1 sibling, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 20:35 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

Interim solution until support for SIM 'ready' notification is supported.
---
Changes:
 o Fixed style issues (tabs and newlines)

 plugins/ste.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index f9875fd..5fecd5e 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -60,8 +60,13 @@
 #include <drivers/stemodem/caif_socket.h>
 #include <drivers/stemodem/if_caif.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
+
 struct ste_data {
 	GAtChat *chat;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 };
 
 static int ste_probe(struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 
 	g_at_chat_unref(data->chat);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
+
 	g_free(data);
 }
 
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)
 	ofono_info("%s", str);
 }
 
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	/* Modem returns +CME ERROR: 10 if SIM is not ready. */
+	if (!ok && result->final_or_pdu &&
+			!strcmp(result->final_or_pdu, "+CME ERROR: 10") &&
+			data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* Modem returns ERROR if there is no SIM in slot. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
+
+	g_at_chat_send(data->chat, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
+}
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 
 	DBG("");
 
-	if (!ok)
+	if (!ok) {
 		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
 
-	ofono_modem_set_powered(modem, TRUE);
+	init_simpin_check(modem);
 }
 
 static int ste_enable(struct ofono_modem *modem)
@@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(data->chat, ste_debug, NULL);
 
-	g_at_chat_send(data->chat, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+	g_at_chat_send(data->chat, "AT&F E0 V1 X4 &C1 +CMEE=1",
+			NULL, NULL, NULL, NULL);
 	g_at_chat_send(data->chat, "AT+CFUN=1", NULL, cfun_enable, modem, NULL);
 
 	return -EINPROGRESS;
-- 
1.6.3.3


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

* [PATCH v3 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-16 20:35     ` [PATCH v3 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:35       ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35         ` [PATCH v3 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  0 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 20:35 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
 Makefile.am                       |    3 +-
 drivers/stemodem/radio-settings.c |  225 +++++++++++++++++++++++++++++++++++++
 drivers/stemodem/stemodem.c       |    2 +
 drivers/stemodem/stemodem.h       |    2 +
 4 files changed, 231 insertions(+), 1 deletions(-)
 create mode 100644 drivers/stemodem/radio-settings.c

diff --git a/Makefile.am b/Makefile.am
index 16a3a3d..9462743 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -204,7 +204,8 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/stemodem/voicecall.c \
 			drivers/stemodem/gprs-context.c \
 			drivers/stemodem/caif_socket.h \
-			drivers/stemodem/if_caif.h
+			drivers/stemodem/if_caif.h \
+			drivers/stemodem/radio-settings.c
 
 builtin_modules += phonesim
 builtin_sources += plugins/phonesim.c
diff --git a/drivers/stemodem/radio-settings.c b/drivers/stemodem/radio-settings.c
new file mode 100644
index 0000000..49a7906
--- /dev/null
+++ b/drivers/stemodem/radio-settings.c
@@ -0,0 +1,225 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *  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 <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/radio-settings.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "stemodem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { "+CFUN:", NULL };
+
+struct radio_settings_data {
+	GAtChat *chat;
+};
+
+enum ste_radio_mode {
+	STE_RADIO_OFF = 0,
+	STE_RADIO_ON = 1,
+	STE_RADIO_FLIGHT_MODE = 4,
+	STE_RADIO_GSM_ONLY = 5,
+	STE_RADIO_WCDMA_ONLY = 6
+};
+
+static gboolean ste_mode_to_ofono_mode(enum ste_radio_mode stemode,
+				enum ofono_radio_access_mode *mode)
+{
+	switch (stemode) {
+	case STE_RADIO_ON:
+		*mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		return TRUE;
+	case STE_RADIO_GSM_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		return TRUE;
+	case STE_RADIO_WCDMA_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		return TRUE;
+	default:
+		return FALSE;
+	}
+}
+
+static gboolean ofono_mode_to_ste_mode(enum ofono_radio_access_mode mode,
+				enum ste_radio_mode *stemode)
+{
+	switch (mode) {
+	case OFONO_RADIO_ACCESS_MODE_ANY:
+		*stemode = STE_RADIO_ON;
+		return TRUE;
+	case OFONO_RADIO_ACCESS_MODE_GSM:
+		*stemode = STE_RADIO_GSM_ONLY;
+		return TRUE;
+
+	case OFONO_RADIO_ACCESS_MODE_UMTS:
+		*stemode = STE_RADIO_WCDMA_ONLY;
+		return TRUE;
+	default:
+		return FALSE;
+	}
+}
+
+static void sterat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
+	enum ofono_radio_access_mode mode;
+	struct ofono_error error;
+	GAtResultIter iter;
+	int value;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CFUN:"))
+		goto err;
+
+	if (!g_at_result_iter_next_number(&iter, &value))
+		goto err;
+
+	if (!ste_mode_to_ofono_mode(value, &mode))
+		goto err;
+
+	CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
+
+	return;
+
+err:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void ste_query_rat_mode(struct ofono_radio_settings *rs,
+				ofono_radio_settings_rat_mode_query_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(rsd->chat, "AT+CFUN?", cfun_prefix,
+					sterat_query_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, -1, data);
+		g_free(cbd);
+	}
+}
+
+static void sterat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, cbd->data);
+		return;
+	}
+
+	CALLBACK_WITH_SUCCESS(cb, cbd->data);
+}
+
+static void ste_set_rat_mode(struct ofono_radio_settings *rs,
+				enum ofono_radio_access_mode mode,
+				ofono_radio_settings_rat_mode_set_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[20];
+	enum ste_radio_mode value;
+
+	if (!ofono_mode_to_ste_mode(mode, &value)) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+		return;
+	}
+
+	snprintf(buf, sizeof(buf), "AT+CFUN=%u", value);
+
+	if (g_at_chat_send(rsd->chat, buf, none_prefix,
+					sterat_modify_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+	}
+}
+
+static int ste_radio_settings_probe(struct ofono_radio_settings *rs,
+					unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct radio_settings_data *rsd;
+	rsd = g_try_new0(struct radio_settings_data, 1);
+	if (!rsd)
+		return -ENOMEM;
+
+	rsd->chat = chat;
+
+	ofono_radio_settings_set_data(rs, rsd);
+	ofono_radio_settings_register(rs);
+
+	return 0;
+}
+
+static void ste_radio_settings_remove(struct ofono_radio_settings *rs)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	ofono_radio_settings_set_data(rs, NULL);
+	g_free(rsd);
+}
+
+static struct ofono_radio_settings_driver driver = {
+	.name			= "stemodem",
+	.probe			= ste_radio_settings_probe,
+	.remove		= ste_radio_settings_remove,
+	.query_rat_mode	= ste_query_rat_mode,
+	.set_rat_mode		= ste_set_rat_mode
+};
+
+void ste_radio_settings_init()
+{
+	ofono_radio_settings_driver_register(&driver);
+}
+
+void ste_radio_settings_exit()
+{
+	ofono_radio_settings_driver_unregister(&driver);
+}
diff --git a/drivers/stemodem/stemodem.c b/drivers/stemodem/stemodem.c
index c18a8b5..ebc1c70 100644
--- a/drivers/stemodem/stemodem.c
+++ b/drivers/stemodem/stemodem.c
@@ -38,6 +38,7 @@ static int stemodem_init(void)
 {
 	ste_voicecall_init();
 	ste_gprs_context_init();
+	ste_radio_settings_init();
 
 	return 0;
 }
@@ -46,6 +47,7 @@ static void stemodem_exit(void)
 {
 	ste_voicecall_exit();
 	ste_gprs_context_exit();
+	ste_radio_settings_exit();
 }
 
 OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
diff --git a/drivers/stemodem/stemodem.h b/drivers/stemodem/stemodem.h
index 267e001..b1691a2 100644
--- a/drivers/stemodem/stemodem.h
+++ b/drivers/stemodem/stemodem.h
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();
 extern void ste_voicecall_init();
 extern void ste_voicecall_exit();
 
+extern void ste_radio_settings_init();
+extern void ste_radio_settings_exit();
-- 
1.6.3.3


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

* [PATCH v3 5/7] plugins/ste: Add Radio-Settings
  2010-08-16 20:35       ` [PATCH v3 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:35         ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35           ` [PATCH v3 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  0 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 20:35 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
 plugins/ste.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 5fecd5e..5a71945 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -55,6 +55,7 @@
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/stk.h>
+#include <ofono/radio-settings.h>
 #include <drivers/atmodem/vendor.h>
 
 #include <drivers/stemodem/caif_socket.h>
@@ -293,6 +294,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 	gprs = ofono_gprs_create(modem,
 			OFONO_VENDOR_STE, "atmodem", data->chat);
 	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->chat);
 	gc = ofono_gprs_context_create(modem, 0, "stemodem", data->chat);
 
 	if (gprs && gc)
-- 
1.6.3.3


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

* [PATCH v3 6/7] stemodem: Use RTNL for creating CAIF interface
  2010-08-16 20:35         ` [PATCH v3 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:35           ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35             ` [PATCH v3 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  0 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 20:35 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

CAIF in Linux kernel 2.6.35 must use RTNL for configuring
CAIF interfaces.
---
 drivers/stemodem/gprs-context.c |   51 +++++--
 drivers/stemodem/rtnl.c         |  318 +++++++++++++++++++++++++++++++++++++++
 drivers/stemodem/rtnl.h         |   24 +++
 3 files changed, 380 insertions(+), 13 deletions(-)
 create mode 100644 drivers/stemodem/rtnl.c
 create mode 100644 drivers/stemodem/rtnl.h

diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index ace9d6e..591df33 100644
--- a/drivers/stemodem/gprs-context.c
+++ b/drivers/stemodem/gprs-context.c
@@ -43,8 +43,9 @@
 
 #include "gatchat.h"
 #include "gatresult.h"
+
+#include "rtnl.h"
 #include "stemodem.h"
-#include "caif_socket.h"
 #include "if_caif.h"
 
 #define MAX_CAIF_DEVICES 7
@@ -68,7 +69,8 @@ struct conn_info {
 	unsigned int cid;
 	unsigned int device;
 	unsigned int channel_id;
-	char interface[10];
+	char ifname[16];
+	int ifindex;
 };
 
 struct eppsd_response {
@@ -171,17 +173,40 @@ static struct conn_info *conn_info_create(unsigned int device,
 /*
  * Creates a new IP interface for CAIF.
  */
-static gboolean caif_if_create(const char *interface, unsigned int connid)
+static gboolean caif_if_create(struct conn_info *conn)
 {
-	return FALSE;
+
+	strcpy(conn->ifname, "caif%d");
+	if (rtnl_create_caif_interface(IFLA_CAIF_IPV4_CONNID,
+					conn->channel_id,
+					conn->ifname,
+					&conn->ifindex) < 0) {
+		DBG("Failed to create IP interface for CAIF");
+		return FALSE;
+	}
+
+	DBG("created CAIF interface ch:%d ifname:%s ifindex:%d\n",
+		conn->channel_id, conn->ifname, conn->ifindex);
+
+	return TRUE;
 }
 
 /*
  * Removes IP interface for CAIF.
  */
-static gboolean caif_if_remove(const char *interface, unsigned int connid)
+static gboolean caif_if_remove(struct conn_info *conn)
 {
-	return FALSE;
+
+	if (rtnl_delete_caif_interface(conn->ifindex) < 0) {
+		ofono_error("Failed to delete caif interface %s",
+			conn->ifname);
+		return FALSE;
+	}
+
+	DBG("removed CAIF interface ch:%d ifname:%s ifindex:%d\n",
+		conn->channel_id, conn->ifname, conn->ifindex);
+
+	return TRUE;
 }
 
 static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
@@ -211,9 +236,9 @@ static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
 
 	conn = l->data;
 
-	if (!caif_if_remove(conn->interface, conn->channel_id)) {
+	if (!caif_if_remove(conn)) {
 		DBG("Failed to remove caif interface %s.",
-				conn->interface);
+				conn->ifname);
 	}
 
 	conn->cid = 0;
@@ -283,16 +308,16 @@ static void ste_eppsd_up_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	dns[1] = rsp.dns_server2;
 	dns[2] = NULL;
 
-	sprintf(conn->interface, "caif%u", conn->device);
+	sprintf(conn->ifname, "caif%u", conn->device);
 
-	if (!caif_if_create(conn->interface, conn->channel_id)) {
+	if (!caif_if_create(conn)) {
 		ofono_error("Failed to create caif interface %s.",
-				conn->interface);
+				conn->ifname);
 		CALLBACK_WITH_SUCCESS(cb, NULL, FALSE, rsp.ip_address,
 				rsp.subnet_mask, rsp.default_gateway,
 				dns, cbd->data);
 	} else {
-		CALLBACK_WITH_SUCCESS(cb, conn->interface,
+		CALLBACK_WITH_SUCCESS(cb, conn->ifname,
 				FALSE, rsp.ip_address, rsp.subnet_mask,
 				rsp.default_gateway, dns, cbd->data);
 	}
@@ -544,7 +569,7 @@ static void ste_gprs_context_remove(struct ofono_gprs_context *gc)
 static struct ofono_gprs_context_driver driver = {
 	.name			= "stemodem",
 	.probe			= ste_gprs_context_probe,
-	.remove			= ste_gprs_context_remove,
+	.remove		= ste_gprs_context_remove,
 	.activate_primary	= ste_gprs_activate_primary,
 	.deactivate_primary	= ste_gprs_deactivate_primary,
 };
diff --git a/drivers/stemodem/rtnl.c b/drivers/stemodem/rtnl.c
new file mode 100644
index 0000000..7990810
--- /dev/null
+++ b/drivers/stemodem/rtnl.c
@@ -0,0 +1,318 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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 <config.h>
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <net/if_arp.h>
+#include <linux/rtnetlink.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+
+#include "if_caif.h"
+#include "rtnl.h"
+
+#define NLMSG_TAIL(nmsg) \
+	((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
+
+struct iplink_req {
+	struct nlmsghdr n;
+	struct ifinfomsg i;
+	char pad[1024];
+	int ifindex;
+	char ifname[16];
+	int result;
+};
+
+static guint32 ipconfig_seqnr = 1;
+
+static gboolean get_ifname(struct ifinfomsg *msg, int bytes,
+			const char **ifname)
+{
+	struct rtattr *attr;
+
+	for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
+			attr = RTA_NEXT(attr, bytes))
+
+		if (attr->rta_type == IFLA_IFNAME &&
+				ifname != NULL) {
+			*ifname = RTA_DATA(attr);
+			return TRUE;
+		}
+
+	return FALSE;
+}
+
+static void handle_rtnl_response(struct iplink_req *req, unsigned short type,
+					int index, unsigned flags,
+					unsigned change, struct ifinfomsg *msg,
+					int bytes)
+{
+	const char *ifname = NULL;
+
+	get_ifname(msg, bytes, &ifname);
+	req->ifindex = index;
+	strncpy(req->ifname, ifname,
+			sizeof(req->ifname));
+	req->ifname[sizeof(req->ifname)-1] = '\0';
+}
+
+static int send_iplink_req(int sk, struct iplink_req *req)
+{
+	struct sockaddr_nl addr;
+
+	memset(&addr, 0, sizeof(addr));
+	addr.nl_family = AF_NETLINK;
+
+	return sendto(sk, req, req->n.nlmsg_len, 0,
+			(struct sockaddr *) &addr, sizeof(addr));
+}
+
+static int parse_rtnl_message(void *buf, size_t len, struct iplink_req *req)
+{
+	struct ifinfomsg *msg;
+
+	while (len > 0) {
+		struct nlmsghdr *hdr = buf;
+		struct nlmsgerr *err;
+
+		if (!NLMSG_OK(hdr, len))
+			break;
+
+		if (hdr->nlmsg_type == NLMSG_ERROR) {
+			err = NLMSG_DATA(hdr);
+			DBG("RTNL failed: seq:%d error %d (%s)",
+					hdr->nlmsg_seq, err->error,
+					strerror(-err->error));
+			req->result = err->error;
+			return err->error;
+		}
+
+		else if (hdr->nlmsg_type == RTM_NEWLINK ||
+			hdr->nlmsg_type == RTM_DELLINK) {
+			msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
+			handle_rtnl_response(req, msg->ifi_type,
+					msg->ifi_index, msg->ifi_flags,
+					msg->ifi_change, msg,
+					IFA_PAYLOAD(hdr));
+			break;
+		} else
+			return -1;
+
+		len -= hdr->nlmsg_len;
+		buf += hdr->nlmsg_len;
+	}
+	return 1;
+}
+
+static int netlink_get_response(int sk, struct iplink_req *req)
+{
+	unsigned char buf[4096];
+	int ret;
+
+	memset(buf, 0, sizeof(buf));
+
+	do {
+		ret = read(sk, buf, sizeof(buf));
+		if (ret < 0)
+			break;
+		ret = parse_rtnl_message(buf, sizeof(buf), req);
+	} while (ret > 0);
+
+	return ret;
+}
+
+static int add_attribute(struct nlmsghdr *n, int maxlen, int type,
+			const void *data, int datalen)
+{
+	int len = RTA_LENGTH(datalen);
+	struct rtattr *rta;
+
+	if ((int)(NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) {
+		DBG("attribute to large for message %d %d %d\n",
+				n->nlmsg_len, len, maxlen);
+		return -1;
+	}
+
+	rta = NLMSG_TAIL(n);
+	rta->rta_type = type;
+	rta->rta_len = len;
+	memcpy(RTA_DATA(rta), data, datalen);
+	n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
+
+	return 0;
+}
+
+static int create_caif_interface(int sk, struct iplink_req *req,
+					int connection_type, char *ifname,
+					int nsapi, int loop_enabled)
+{
+	char type[] = "caif";
+	struct rtattr *linkinfo;
+	struct rtattr *data;
+
+	req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+	req->n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL|NLM_F_ACK;
+	req->n.nlmsg_type = RTM_NEWLINK;
+	req->n.nlmsg_seq = ipconfig_seqnr++;
+	req->i.ifi_family = AF_UNSPEC;
+
+	linkinfo = NLMSG_TAIL(&req->n);
+
+	add_attribute(&req->n, sizeof(*req), IFLA_LINKINFO,
+			NULL, 0);
+
+	add_attribute(&req->n, sizeof(*req), IFLA_INFO_KIND,
+			type, strlen(type));
+
+	add_attribute(&req->n, sizeof(*req), IFLA_IFNAME,
+			ifname, strlen(ifname));
+
+	data = NLMSG_TAIL(&req->n);
+	add_attribute(&req->n, sizeof(*req), IFLA_INFO_DATA,
+			NULL, 0);
+
+	if (connection_type == IFLA_CAIF_IPV4_CONNID)
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_IPV4_CONNID, &nsapi, sizeof(nsapi));
+	else if (connection_type == IFLA_CAIF_IPV6_CONNID)
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_IPV6_CONNID, &nsapi, sizeof(nsapi));
+	else {
+		DBG("unsupported linktype\n");
+		g_free(req);
+		return -1;
+	}
+
+	if (loop_enabled) {
+		int loop;
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_LOOPBACK, &loop, sizeof(loop));
+	}
+
+	data->rta_len = (void *)NLMSG_TAIL(&req->n) - (void *)data;
+
+	linkinfo->rta_len = (void *)NLMSG_TAIL(&req->n) - (void *)linkinfo;
+
+	return send_iplink_req(sk, req);
+}
+
+static int destroy_caif_interface(int sk, struct iplink_req *req, int ifindex)
+{
+
+	req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+	req->n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL|NLM_F_ACK;
+	req->n.nlmsg_type = RTM_DELLINK;
+	req->n.nlmsg_seq = ipconfig_seqnr++;
+	req->i.ifi_family = AF_UNSPEC;
+	req->i.ifi_index = ifindex;
+
+	return send_iplink_req(sk, req);
+}
+
+static int rtnl_init(void)
+{
+	struct sockaddr_nl addr;
+	int sk, ret;
+
+	sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
+	if (sk < 0)
+		return sk;
+
+	memset(&addr, 0, sizeof(addr));
+	addr.nl_family = AF_NETLINK;
+	addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE;
+
+	ret = bind(sk, (struct sockaddr *) &addr, sizeof(addr));
+
+	if (ret < 0) {
+		close(sk);
+		return ret;
+	}
+
+	return sk;
+}
+
+/* Note ifname is in/out and must be minimum size 16 */
+int rtnl_create_caif_interface(int type, int conn_id, char ifname[16],
+					int *ifindex)
+{
+	int sk, ret;
+	int loop = 0;
+	struct iplink_req req;
+
+	memset(&req, 0, sizeof(req));
+	*ifindex = -1;
+
+	sk = rtnl_init();
+	ret = sk;
+	if (sk < 0)
+		goto out;
+
+	ret = create_caif_interface(sk, &req, type, ifname, conn_id, loop);
+	if (ret < 0)
+		goto out;
+
+	ret = netlink_get_response(sk, &req);
+	if (ret < 0)
+		goto out;
+
+	strncpy(ifname, req.ifname, sizeof(req.ifname));
+	ifname[sizeof(req.ifname)-1] = '\0';
+	*ifindex = req.ifindex;
+	ret = req.result;
+
+out:
+	close(sk);
+	return ret;
+}
+
+int rtnl_delete_caif_interface(int ifid)
+{
+	struct iplink_req req;
+	int sk, ret;
+
+	memset(&req, 0, sizeof(req));
+
+	sk = rtnl_init();
+	ret = sk;
+	if (sk < 0)
+		goto out;
+
+	ret = destroy_caif_interface(sk, &req, ifid);
+	if (ret < 0)
+		goto out;
+
+	ret = netlink_get_response(sk, &req);
+	if (ret < 0)
+		goto out;
+
+	ret = req.result;
+
+out:
+	close(sk);
+	return ret;
+}
diff --git a/drivers/stemodem/rtnl.h b/drivers/stemodem/rtnl.h
new file mode 100644
index 0000000..8f6a84f
--- /dev/null
+++ b/drivers/stemodem/rtnl.h
@@ -0,0 +1,24 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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
+ *
+ */
+
+extern int rtnl_create_caif_interface(int type, int conn_id, char ifname[16],
+					int *ifindex);
+extern int rtnl_delete_caif_interface(int ifid);
-- 
1.6.3.3


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

* [PATCH v3 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
  2010-08-16 20:35           ` [PATCH v3 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:35             ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  0 siblings, 0 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 20:35 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
 plugins/modem.conf  |    5 +++++
 plugins/modemconf.c |    1 +
 plugins/ste.c       |   20 +++++++++++++++++++-
 3 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/plugins/modem.conf b/plugins/modem.conf
index 66bf932..b577114 100644
--- a/plugins/modem.conf
+++ b/plugins/modem.conf
@@ -44,3 +44,8 @@
 #[n900]
 #Driver=n900modem
 #Interface=phonet0
+
+# Sample STE modem
+#[ste]
+#Interface=cfttyS0
+#Driver=ste
diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 3747cd9..d7b1354 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -138,6 +138,7 @@ static struct {
 	{ "g1",		set_device	},
 	{ "wavecom",	set_device	},
 	{ "ste",	set_device	},
+	{ "ste",	set_interface	},
 	{ "calypso",	set_device	},
 	{ "palmpre",	set_device	},
 	{ "isimodem",	set_interface	},
diff --git a/plugins/ste.c b/plugins/ste.c
index 5a71945..e737bbb 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <net/if.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)
 	if (!device) {
 		struct sockaddr_caif addr;
 		int err;
+		const char *interface;
 
 		/* Create a CAIF socket for AT Service */
-		fd = socket(AF_CAIF, SOCK_SEQPACKET, CAIFPROTO_AT);
+		fd = socket(AF_CAIF, SOCK_STREAM, CAIFPROTO_AT);
 		if (fd < 0) {
 			ofono_error("Failed to create CAIF socket for AT");
 			return -EIO;
 		}
 
+		/* Bind CAIF socket to specified interface */
+		interface = ofono_modem_get_string(modem, "Interface");
+		if (interface) {
+			struct ifreq ifreq;
+			memset(&ifreq, 0, sizeof(ifreq));
+			strcpy(ifreq.ifr_name, interface);
+			err = setsockopt(fd, SOL_SOCKET,
+					SO_BINDTODEVICE, &ifreq, sizeof(ifreq));
+			if (err < 0) {
+				ofono_error("Failed to bind caif socket "
+					"to interface");
+				close(fd);
+				return err;
+			}
+		}
+
 		memset(&addr, 0, sizeof(addr));
 		addr.family = AF_CAIF;
 		addr.u.at.type = CAIF_ATTYPE_PLAIN;
-- 
1.6.3.3


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

* Re: [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver.
  2010-08-16 20:35 ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35   ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:44   ` Marcel Holtmann
  1 sibling, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 20:44 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> > ... The build system builds the plugins
> > properly and you can cross reference modem drivers from your modem
> > plugin without any problems.
> 
> Simply refering to MBM driver from ste.c
> 
>  plugins/ste.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/plugins/ste.c b/plugins/ste.c
> index f3ae0b2..9cb49d3 100644
> --- a/plugins/ste.c
> +++ b/plugins/ste.c
> @@ -54,6 +54,7 @@
>  #include <ofono/voicecall.h>
>  #include <ofono/gprs.h>
>  #include <ofono/gprs-context.h>
> +#include <ofono/stk.h>
>  #include <drivers/atmodem/vendor.h>
>  
>  #include <drivers/stemodem/caif_socket.h>
> @@ -241,6 +242,7 @@ static void ste_post_sim(struct ofono_modem *modem)
>  
>  	gprs = ofono_gprs_create(modem,
>  			OFONO_VENDOR_STE, "atmodem", data->chat);
> +	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
>  	gc = ofono_gprs_context_create(modem, 0, "stemodem", data->chat);
>  
>  	if (gprs && gc)

one minor nitpick here. Can you please not squeeze this in between GPRS
and GPRS Context atoms. Put it at the same location the MBM plugin does.

Regards

Marcel



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

* Re: [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
  2010-08-16 20:35   ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 20:35     ` [PATCH v3 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 20:45     ` Marcel Holtmann
  1 sibling, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 20:45 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> >do we really wanna create another vendor quirk here. If both modems
> >behave identical then just pass OFONO_VENDOR_MBM in the SIM atom
> >registration and be done with it.
> 
> Re-use the MBM quirk rather than adding STE quirks in atmodem/sim.c
> 
> ---
>  plugins/ste.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/plugins/ste.c b/plugins/ste.c
> index 9cb49d3..9d9afd6 100644
> --- a/plugins/ste.c
> +++ b/plugins/ste.c
> @@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)
>  
>  	ofono_devinfo_create(modem, 0, "atmodem", data->chat);
>  	sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
> -	ofono_voicecall_create(modem, 0, "stemodem", data->chat);
> +	ofono_voicecall_create(modem, OFONO_VENDOR_MBM, "stemodem", data->chat);

this looks wrong. You are using a STE specific modem driver already. Why
do you need to pass a quirk here as well.

Did I confuse you with one of my other replies or did I confuse myself
here in the review?

Regards

Marcel



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

* [PATCH v4 1/7] plugins/ste: Include STK support from MBM driver.
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (7 preceding siblings ...)
  2010-08-16 20:35 ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:12 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12   ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:58   ` [PATCH v4 1/7] plugins/ste: Include STK support from MBM driver Marcel Holtmann
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  9 siblings, 2 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 21:12 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
Marcel Holtmann wrote:
>>> ... The build system builds the plugins
>>> properly and you can cross reference modem drivers from your modem
>>> plugin without any problems.
>>
>>Simply refering to MBM driver from ste.c
>>
>one minor nitpick here. Can you please not squeeze this in between GPRS
>and GPRS Context atoms. Put it at the same location the MBM plugin does.

Fixed.

---
 plugins/ste.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index f3ae0b2..5b34704 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -54,6 +54,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
+#include <ofono/stk.h>
 #include <drivers/atmodem/vendor.h>
 
 #include <drivers/stemodem/caif_socket.h>
@@ -228,6 +229,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
+	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
 	ofono_ussd_create(modem, 0, "atmodem", data->chat);
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
 	ofono_call_settings_create(modem, 0, "atmodem", data->chat);
-- 
1.6.3.3


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

* [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
  2010-08-16 21:12 ` [PATCH v4 " Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:12   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12     ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 22:06     ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Marcel Holtmann
  2010-08-16 21:58   ` [PATCH v4 1/7] plugins/ste: Include STK support from MBM driver Marcel Holtmann
  1 sibling, 2 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 21:12 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
Marcel Holtmann wrote:
...
>do we really wanna create another vendor quirk here. If both modems
>behave identical then just pass OFONO_VENDOR_MBM in the SIM atom
>registration and be done with it.

Re-use the MBM quirk rather than adding STE quirks in atmodem/sim.c

---
 plugins/ste.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 9cb49d3..9d9afd6 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)
 
 	ofono_devinfo_create(modem, 0, "atmodem", data->chat);
 	sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
-	ofono_voicecall_create(modem, 0, "stemodem", data->chat);
+	ofono_voicecall_create(modem, OFONO_VENDOR_MBM, "stemodem", data->chat);
 
 	if (sim)
 		ofono_sim_inserted_notify(sim, TRUE);
-- 
1.6.3.3


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

* [PATCH v4 3/7] stemodem: Add polling for SIM ready.
  2010-08-16 21:12   ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:12     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12       ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 22:08       ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Marcel Holtmann
  2010-08-16 22:06     ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Marcel Holtmann
  1 sibling, 2 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 21:12 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

Interim solution until support for SIM 'ready' notification is supported.
---
Changes:
 o Fixed style issues (tabs and newlines)

 plugins/ste.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index f9875fd..5fecd5e 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -60,8 +60,13 @@
 #include <drivers/stemodem/caif_socket.h>
 #include <drivers/stemodem/if_caif.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
+
 struct ste_data {
 	GAtChat *chat;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 };
 
 static int ste_probe(struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 
 	g_at_chat_unref(data->chat);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
+
 	g_free(data);
 }
 
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)
 	ofono_info("%s", str);
 }
 
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	/* Modem returns +CME ERROR: 10 if SIM is not ready. */
+	if (!ok && result->final_or_pdu &&
+			!strcmp(result->final_or_pdu, "+CME ERROR: 10") &&
+			data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* Modem returns ERROR if there is no SIM in slot. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
+
+	g_at_chat_send(data->chat, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
+}
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 
 	DBG("");
 
-	if (!ok)
+	if (!ok) {
 		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
 
-	ofono_modem_set_powered(modem, TRUE);
+	init_simpin_check(modem);
 }
 
 static int ste_enable(struct ofono_modem *modem)
@@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(data->chat, ste_debug, NULL);
 
-	g_at_chat_send(data->chat, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+	g_at_chat_send(data->chat, "AT&F E0 V1 X4 &C1 +CMEE=1",
+			NULL, NULL, NULL, NULL);
 	g_at_chat_send(data->chat, "AT+CFUN=1", NULL, cfun_enable, modem, NULL);
 
 	return -EINPROGRESS;
-- 
1.6.3.3


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

* [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-16 21:12     ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:12       ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12         ` [PATCH v4 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 22:05         ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Marcel Holtmann
  2010-08-16 22:08       ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Marcel Holtmann
  1 sibling, 2 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 21:12 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
 Makefile.am                       |    3 +-
 drivers/stemodem/radio-settings.c |  225 +++++++++++++++++++++++++++++++++++++
 drivers/stemodem/stemodem.c       |    2 +
 drivers/stemodem/stemodem.h       |    2 +
 4 files changed, 231 insertions(+), 1 deletions(-)
 create mode 100644 drivers/stemodem/radio-settings.c

diff --git a/Makefile.am b/Makefile.am
index 16a3a3d..9462743 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -204,7 +204,8 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/stemodem/voicecall.c \
 			drivers/stemodem/gprs-context.c \
 			drivers/stemodem/caif_socket.h \
-			drivers/stemodem/if_caif.h
+			drivers/stemodem/if_caif.h \
+			drivers/stemodem/radio-settings.c
 
 builtin_modules += phonesim
 builtin_sources += plugins/phonesim.c
diff --git a/drivers/stemodem/radio-settings.c b/drivers/stemodem/radio-settings.c
new file mode 100644
index 0000000..49a7906
--- /dev/null
+++ b/drivers/stemodem/radio-settings.c
@@ -0,0 +1,225 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *  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 <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/radio-settings.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "stemodem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { "+CFUN:", NULL };
+
+struct radio_settings_data {
+	GAtChat *chat;
+};
+
+enum ste_radio_mode {
+	STE_RADIO_OFF = 0,
+	STE_RADIO_ON = 1,
+	STE_RADIO_FLIGHT_MODE = 4,
+	STE_RADIO_GSM_ONLY = 5,
+	STE_RADIO_WCDMA_ONLY = 6
+};
+
+static gboolean ste_mode_to_ofono_mode(enum ste_radio_mode stemode,
+				enum ofono_radio_access_mode *mode)
+{
+	switch (stemode) {
+	case STE_RADIO_ON:
+		*mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		return TRUE;
+	case STE_RADIO_GSM_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		return TRUE;
+	case STE_RADIO_WCDMA_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		return TRUE;
+	default:
+		return FALSE;
+	}
+}
+
+static gboolean ofono_mode_to_ste_mode(enum ofono_radio_access_mode mode,
+				enum ste_radio_mode *stemode)
+{
+	switch (mode) {
+	case OFONO_RADIO_ACCESS_MODE_ANY:
+		*stemode = STE_RADIO_ON;
+		return TRUE;
+	case OFONO_RADIO_ACCESS_MODE_GSM:
+		*stemode = STE_RADIO_GSM_ONLY;
+		return TRUE;
+
+	case OFONO_RADIO_ACCESS_MODE_UMTS:
+		*stemode = STE_RADIO_WCDMA_ONLY;
+		return TRUE;
+	default:
+		return FALSE;
+	}
+}
+
+static void sterat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
+	enum ofono_radio_access_mode mode;
+	struct ofono_error error;
+	GAtResultIter iter;
+	int value;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CFUN:"))
+		goto err;
+
+	if (!g_at_result_iter_next_number(&iter, &value))
+		goto err;
+
+	if (!ste_mode_to_ofono_mode(value, &mode))
+		goto err;
+
+	CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
+
+	return;
+
+err:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void ste_query_rat_mode(struct ofono_radio_settings *rs,
+				ofono_radio_settings_rat_mode_query_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(rsd->chat, "AT+CFUN?", cfun_prefix,
+					sterat_query_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, -1, data);
+		g_free(cbd);
+	}
+}
+
+static void sterat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, cbd->data);
+		return;
+	}
+
+	CALLBACK_WITH_SUCCESS(cb, cbd->data);
+}
+
+static void ste_set_rat_mode(struct ofono_radio_settings *rs,
+				enum ofono_radio_access_mode mode,
+				ofono_radio_settings_rat_mode_set_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[20];
+	enum ste_radio_mode value;
+
+	if (!ofono_mode_to_ste_mode(mode, &value)) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+		return;
+	}
+
+	snprintf(buf, sizeof(buf), "AT+CFUN=%u", value);
+
+	if (g_at_chat_send(rsd->chat, buf, none_prefix,
+					sterat_modify_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+	}
+}
+
+static int ste_radio_settings_probe(struct ofono_radio_settings *rs,
+					unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct radio_settings_data *rsd;
+	rsd = g_try_new0(struct radio_settings_data, 1);
+	if (!rsd)
+		return -ENOMEM;
+
+	rsd->chat = chat;
+
+	ofono_radio_settings_set_data(rs, rsd);
+	ofono_radio_settings_register(rs);
+
+	return 0;
+}
+
+static void ste_radio_settings_remove(struct ofono_radio_settings *rs)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	ofono_radio_settings_set_data(rs, NULL);
+	g_free(rsd);
+}
+
+static struct ofono_radio_settings_driver driver = {
+	.name			= "stemodem",
+	.probe			= ste_radio_settings_probe,
+	.remove		= ste_radio_settings_remove,
+	.query_rat_mode	= ste_query_rat_mode,
+	.set_rat_mode		= ste_set_rat_mode
+};
+
+void ste_radio_settings_init()
+{
+	ofono_radio_settings_driver_register(&driver);
+}
+
+void ste_radio_settings_exit()
+{
+	ofono_radio_settings_driver_unregister(&driver);
+}
diff --git a/drivers/stemodem/stemodem.c b/drivers/stemodem/stemodem.c
index c18a8b5..ebc1c70 100644
--- a/drivers/stemodem/stemodem.c
+++ b/drivers/stemodem/stemodem.c
@@ -38,6 +38,7 @@ static int stemodem_init(void)
 {
 	ste_voicecall_init();
 	ste_gprs_context_init();
+	ste_radio_settings_init();
 
 	return 0;
 }
@@ -46,6 +47,7 @@ static void stemodem_exit(void)
 {
 	ste_voicecall_exit();
 	ste_gprs_context_exit();
+	ste_radio_settings_exit();
 }
 
 OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
diff --git a/drivers/stemodem/stemodem.h b/drivers/stemodem/stemodem.h
index 267e001..b1691a2 100644
--- a/drivers/stemodem/stemodem.h
+++ b/drivers/stemodem/stemodem.h
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();
 extern void ste_voicecall_init();
 extern void ste_voicecall_exit();
 
+extern void ste_radio_settings_init();
+extern void ste_radio_settings_exit();
-- 
1.6.3.3


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

* [PATCH v4 5/7] plugins/ste: Add Radio-Settings
  2010-08-16 21:12       ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:12         ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12           ` [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 22:05         ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Marcel Holtmann
  1 sibling, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 21:12 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
 plugins/ste.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index f1535e3..eeaa324 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -54,6 +54,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
+#include <ofono/radio-settings.h>
 #include <ofono/stk.h>
 #include <drivers/atmodem/vendor.h>
 
@@ -279,6 +280,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 	DBG("%p", modem);
 
 	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->chat);
 	ofono_ussd_create(modem, 0, "atmodem", data->chat);
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
 	ofono_call_settings_create(modem, 0, "atmodem", data->chat);
-- 
1.6.3.3


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

* [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface
  2010-08-16 21:12         ` [PATCH v4 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:12           ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12             ` [PATCH v4 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 22:11             ` [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface Marcel Holtmann
  0 siblings, 2 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 21:12 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

CAIF in Linux kernel 2.6.35 must use RTNL for configuring
CAIF interfaces.
---
 drivers/stemodem/gprs-context.c |   51 +++++--
 drivers/stemodem/rtnl.c         |  318 +++++++++++++++++++++++++++++++++++++++
 drivers/stemodem/rtnl.h         |   24 +++
 3 files changed, 380 insertions(+), 13 deletions(-)
 create mode 100644 drivers/stemodem/rtnl.c
 create mode 100644 drivers/stemodem/rtnl.h

diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index ace9d6e..591df33 100644
--- a/drivers/stemodem/gprs-context.c
+++ b/drivers/stemodem/gprs-context.c
@@ -43,8 +43,9 @@
 
 #include "gatchat.h"
 #include "gatresult.h"
+
+#include "rtnl.h"
 #include "stemodem.h"
-#include "caif_socket.h"
 #include "if_caif.h"
 
 #define MAX_CAIF_DEVICES 7
@@ -68,7 +69,8 @@ struct conn_info {
 	unsigned int cid;
 	unsigned int device;
 	unsigned int channel_id;
-	char interface[10];
+	char ifname[16];
+	int ifindex;
 };
 
 struct eppsd_response {
@@ -171,17 +173,40 @@ static struct conn_info *conn_info_create(unsigned int device,
 /*
  * Creates a new IP interface for CAIF.
  */
-static gboolean caif_if_create(const char *interface, unsigned int connid)
+static gboolean caif_if_create(struct conn_info *conn)
 {
-	return FALSE;
+
+	strcpy(conn->ifname, "caif%d");
+	if (rtnl_create_caif_interface(IFLA_CAIF_IPV4_CONNID,
+					conn->channel_id,
+					conn->ifname,
+					&conn->ifindex) < 0) {
+		DBG("Failed to create IP interface for CAIF");
+		return FALSE;
+	}
+
+	DBG("created CAIF interface ch:%d ifname:%s ifindex:%d\n",
+		conn->channel_id, conn->ifname, conn->ifindex);
+
+	return TRUE;
 }
 
 /*
  * Removes IP interface for CAIF.
  */
-static gboolean caif_if_remove(const char *interface, unsigned int connid)
+static gboolean caif_if_remove(struct conn_info *conn)
 {
-	return FALSE;
+
+	if (rtnl_delete_caif_interface(conn->ifindex) < 0) {
+		ofono_error("Failed to delete caif interface %s",
+			conn->ifname);
+		return FALSE;
+	}
+
+	DBG("removed CAIF interface ch:%d ifname:%s ifindex:%d\n",
+		conn->channel_id, conn->ifname, conn->ifindex);
+
+	return TRUE;
 }
 
 static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
@@ -211,9 +236,9 @@ static void ste_eppsd_down_cb(gboolean ok, GAtResult *result,
 
 	conn = l->data;
 
-	if (!caif_if_remove(conn->interface, conn->channel_id)) {
+	if (!caif_if_remove(conn)) {
 		DBG("Failed to remove caif interface %s.",
-				conn->interface);
+				conn->ifname);
 	}
 
 	conn->cid = 0;
@@ -283,16 +308,16 @@ static void ste_eppsd_up_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	dns[1] = rsp.dns_server2;
 	dns[2] = NULL;
 
-	sprintf(conn->interface, "caif%u", conn->device);
+	sprintf(conn->ifname, "caif%u", conn->device);
 
-	if (!caif_if_create(conn->interface, conn->channel_id)) {
+	if (!caif_if_create(conn)) {
 		ofono_error("Failed to create caif interface %s.",
-				conn->interface);
+				conn->ifname);
 		CALLBACK_WITH_SUCCESS(cb, NULL, FALSE, rsp.ip_address,
 				rsp.subnet_mask, rsp.default_gateway,
 				dns, cbd->data);
 	} else {
-		CALLBACK_WITH_SUCCESS(cb, conn->interface,
+		CALLBACK_WITH_SUCCESS(cb, conn->ifname,
 				FALSE, rsp.ip_address, rsp.subnet_mask,
 				rsp.default_gateway, dns, cbd->data);
 	}
@@ -544,7 +569,7 @@ static void ste_gprs_context_remove(struct ofono_gprs_context *gc)
 static struct ofono_gprs_context_driver driver = {
 	.name			= "stemodem",
 	.probe			= ste_gprs_context_probe,
-	.remove			= ste_gprs_context_remove,
+	.remove		= ste_gprs_context_remove,
 	.activate_primary	= ste_gprs_activate_primary,
 	.deactivate_primary	= ste_gprs_deactivate_primary,
 };
diff --git a/drivers/stemodem/rtnl.c b/drivers/stemodem/rtnl.c
new file mode 100644
index 0000000..7990810
--- /dev/null
+++ b/drivers/stemodem/rtnl.c
@@ -0,0 +1,318 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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 <config.h>
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <net/if_arp.h>
+#include <linux/rtnetlink.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+
+#include "if_caif.h"
+#include "rtnl.h"
+
+#define NLMSG_TAIL(nmsg) \
+	((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
+
+struct iplink_req {
+	struct nlmsghdr n;
+	struct ifinfomsg i;
+	char pad[1024];
+	int ifindex;
+	char ifname[16];
+	int result;
+};
+
+static guint32 ipconfig_seqnr = 1;
+
+static gboolean get_ifname(struct ifinfomsg *msg, int bytes,
+			const char **ifname)
+{
+	struct rtattr *attr;
+
+	for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
+			attr = RTA_NEXT(attr, bytes))
+
+		if (attr->rta_type == IFLA_IFNAME &&
+				ifname != NULL) {
+			*ifname = RTA_DATA(attr);
+			return TRUE;
+		}
+
+	return FALSE;
+}
+
+static void handle_rtnl_response(struct iplink_req *req, unsigned short type,
+					int index, unsigned flags,
+					unsigned change, struct ifinfomsg *msg,
+					int bytes)
+{
+	const char *ifname = NULL;
+
+	get_ifname(msg, bytes, &ifname);
+	req->ifindex = index;
+	strncpy(req->ifname, ifname,
+			sizeof(req->ifname));
+	req->ifname[sizeof(req->ifname)-1] = '\0';
+}
+
+static int send_iplink_req(int sk, struct iplink_req *req)
+{
+	struct sockaddr_nl addr;
+
+	memset(&addr, 0, sizeof(addr));
+	addr.nl_family = AF_NETLINK;
+
+	return sendto(sk, req, req->n.nlmsg_len, 0,
+			(struct sockaddr *) &addr, sizeof(addr));
+}
+
+static int parse_rtnl_message(void *buf, size_t len, struct iplink_req *req)
+{
+	struct ifinfomsg *msg;
+
+	while (len > 0) {
+		struct nlmsghdr *hdr = buf;
+		struct nlmsgerr *err;
+
+		if (!NLMSG_OK(hdr, len))
+			break;
+
+		if (hdr->nlmsg_type == NLMSG_ERROR) {
+			err = NLMSG_DATA(hdr);
+			DBG("RTNL failed: seq:%d error %d (%s)",
+					hdr->nlmsg_seq, err->error,
+					strerror(-err->error));
+			req->result = err->error;
+			return err->error;
+		}
+
+		else if (hdr->nlmsg_type == RTM_NEWLINK ||
+			hdr->nlmsg_type == RTM_DELLINK) {
+			msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
+			handle_rtnl_response(req, msg->ifi_type,
+					msg->ifi_index, msg->ifi_flags,
+					msg->ifi_change, msg,
+					IFA_PAYLOAD(hdr));
+			break;
+		} else
+			return -1;
+
+		len -= hdr->nlmsg_len;
+		buf += hdr->nlmsg_len;
+	}
+	return 1;
+}
+
+static int netlink_get_response(int sk, struct iplink_req *req)
+{
+	unsigned char buf[4096];
+	int ret;
+
+	memset(buf, 0, sizeof(buf));
+
+	do {
+		ret = read(sk, buf, sizeof(buf));
+		if (ret < 0)
+			break;
+		ret = parse_rtnl_message(buf, sizeof(buf), req);
+	} while (ret > 0);
+
+	return ret;
+}
+
+static int add_attribute(struct nlmsghdr *n, int maxlen, int type,
+			const void *data, int datalen)
+{
+	int len = RTA_LENGTH(datalen);
+	struct rtattr *rta;
+
+	if ((int)(NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) {
+		DBG("attribute to large for message %d %d %d\n",
+				n->nlmsg_len, len, maxlen);
+		return -1;
+	}
+
+	rta = NLMSG_TAIL(n);
+	rta->rta_type = type;
+	rta->rta_len = len;
+	memcpy(RTA_DATA(rta), data, datalen);
+	n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
+
+	return 0;
+}
+
+static int create_caif_interface(int sk, struct iplink_req *req,
+					int connection_type, char *ifname,
+					int nsapi, int loop_enabled)
+{
+	char type[] = "caif";
+	struct rtattr *linkinfo;
+	struct rtattr *data;
+
+	req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+	req->n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL|NLM_F_ACK;
+	req->n.nlmsg_type = RTM_NEWLINK;
+	req->n.nlmsg_seq = ipconfig_seqnr++;
+	req->i.ifi_family = AF_UNSPEC;
+
+	linkinfo = NLMSG_TAIL(&req->n);
+
+	add_attribute(&req->n, sizeof(*req), IFLA_LINKINFO,
+			NULL, 0);
+
+	add_attribute(&req->n, sizeof(*req), IFLA_INFO_KIND,
+			type, strlen(type));
+
+	add_attribute(&req->n, sizeof(*req), IFLA_IFNAME,
+			ifname, strlen(ifname));
+
+	data = NLMSG_TAIL(&req->n);
+	add_attribute(&req->n, sizeof(*req), IFLA_INFO_DATA,
+			NULL, 0);
+
+	if (connection_type == IFLA_CAIF_IPV4_CONNID)
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_IPV4_CONNID, &nsapi, sizeof(nsapi));
+	else if (connection_type == IFLA_CAIF_IPV6_CONNID)
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_IPV6_CONNID, &nsapi, sizeof(nsapi));
+	else {
+		DBG("unsupported linktype\n");
+		g_free(req);
+		return -1;
+	}
+
+	if (loop_enabled) {
+		int loop;
+		add_attribute(&req->n, sizeof(*req),
+				IFLA_CAIF_LOOPBACK, &loop, sizeof(loop));
+	}
+
+	data->rta_len = (void *)NLMSG_TAIL(&req->n) - (void *)data;
+
+	linkinfo->rta_len = (void *)NLMSG_TAIL(&req->n) - (void *)linkinfo;
+
+	return send_iplink_req(sk, req);
+}
+
+static int destroy_caif_interface(int sk, struct iplink_req *req, int ifindex)
+{
+
+	req->n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
+	req->n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_EXCL|NLM_F_ACK;
+	req->n.nlmsg_type = RTM_DELLINK;
+	req->n.nlmsg_seq = ipconfig_seqnr++;
+	req->i.ifi_family = AF_UNSPEC;
+	req->i.ifi_index = ifindex;
+
+	return send_iplink_req(sk, req);
+}
+
+static int rtnl_init(void)
+{
+	struct sockaddr_nl addr;
+	int sk, ret;
+
+	sk = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
+	if (sk < 0)
+		return sk;
+
+	memset(&addr, 0, sizeof(addr));
+	addr.nl_family = AF_NETLINK;
+	addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE;
+
+	ret = bind(sk, (struct sockaddr *) &addr, sizeof(addr));
+
+	if (ret < 0) {
+		close(sk);
+		return ret;
+	}
+
+	return sk;
+}
+
+/* Note ifname is in/out and must be minimum size 16 */
+int rtnl_create_caif_interface(int type, int conn_id, char ifname[16],
+					int *ifindex)
+{
+	int sk, ret;
+	int loop = 0;
+	struct iplink_req req;
+
+	memset(&req, 0, sizeof(req));
+	*ifindex = -1;
+
+	sk = rtnl_init();
+	ret = sk;
+	if (sk < 0)
+		goto out;
+
+	ret = create_caif_interface(sk, &req, type, ifname, conn_id, loop);
+	if (ret < 0)
+		goto out;
+
+	ret = netlink_get_response(sk, &req);
+	if (ret < 0)
+		goto out;
+
+	strncpy(ifname, req.ifname, sizeof(req.ifname));
+	ifname[sizeof(req.ifname)-1] = '\0';
+	*ifindex = req.ifindex;
+	ret = req.result;
+
+out:
+	close(sk);
+	return ret;
+}
+
+int rtnl_delete_caif_interface(int ifid)
+{
+	struct iplink_req req;
+	int sk, ret;
+
+	memset(&req, 0, sizeof(req));
+
+	sk = rtnl_init();
+	ret = sk;
+	if (sk < 0)
+		goto out;
+
+	ret = destroy_caif_interface(sk, &req, ifid);
+	if (ret < 0)
+		goto out;
+
+	ret = netlink_get_response(sk, &req);
+	if (ret < 0)
+		goto out;
+
+	ret = req.result;
+
+out:
+	close(sk);
+	return ret;
+}
diff --git a/drivers/stemodem/rtnl.h b/drivers/stemodem/rtnl.h
new file mode 100644
index 0000000..8f6a84f
--- /dev/null
+++ b/drivers/stemodem/rtnl.h
@@ -0,0 +1,24 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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
+ *
+ */
+
+extern int rtnl_create_caif_interface(int type, int conn_id, char ifname[16],
+					int *ifindex);
+extern int rtnl_delete_caif_interface(int ifid);
-- 
1.6.3.3


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

* [PATCH v4 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
  2010-08-16 21:12           ` [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:12             ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 22:12               ` Marcel Holtmann
  2010-08-16 22:11             ` [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface Marcel Holtmann
  1 sibling, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-16 21:12 UTC (permalink / raw)
  To: ofono

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

From: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
 plugins/modem.conf  |    5 +++++
 plugins/modemconf.c |    1 +
 plugins/ste.c       |   20 +++++++++++++++++++-
 3 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/plugins/modem.conf b/plugins/modem.conf
index 66bf932..b577114 100644
--- a/plugins/modem.conf
+++ b/plugins/modem.conf
@@ -44,3 +44,8 @@
 #[n900]
 #Driver=n900modem
 #Interface=phonet0
+
+# Sample STE modem
+#[ste]
+#Interface=cfttyS0
+#Driver=ste
diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 3747cd9..d7b1354 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -138,6 +138,7 @@ static struct {
 	{ "g1",		set_device	},
 	{ "wavecom",	set_device	},
 	{ "ste",	set_device	},
+	{ "ste",	set_interface	},
 	{ "calypso",	set_device	},
 	{ "palmpre",	set_device	},
 	{ "isimodem",	set_interface	},
diff --git a/plugins/ste.c b/plugins/ste.c
index 5a71945..e737bbb 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <net/if.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)
 	if (!device) {
 		struct sockaddr_caif addr;
 		int err;
+		const char *interface;
 
 		/* Create a CAIF socket for AT Service */
-		fd = socket(AF_CAIF, SOCK_SEQPACKET, CAIFPROTO_AT);
+		fd = socket(AF_CAIF, SOCK_STREAM, CAIFPROTO_AT);
 		if (fd < 0) {
 			ofono_error("Failed to create CAIF socket for AT");
 			return -EIO;
 		}
 
+		/* Bind CAIF socket to specified interface */
+		interface = ofono_modem_get_string(modem, "Interface");
+		if (interface) {
+			struct ifreq ifreq;
+			memset(&ifreq, 0, sizeof(ifreq));
+			strcpy(ifreq.ifr_name, interface);
+			err = setsockopt(fd, SOL_SOCKET,
+					SO_BINDTODEVICE, &ifreq, sizeof(ifreq));
+			if (err < 0) {
+				ofono_error("Failed to bind caif socket "
+					"to interface");
+				close(fd);
+				return err;
+			}
+		}
+
 		memset(&addr, 0, sizeof(addr));
 		addr.family = AF_CAIF;
 		addr.u.at.type = CAIF_ATTYPE_PLAIN;
-- 
1.6.3.3


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

* Re: [PATCH v4 1/7] plugins/ste: Include STK support from MBM driver.
  2010-08-16 21:12 ` [PATCH v4 " Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12   ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 21:58   ` Marcel Holtmann
  1 sibling, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 21:58 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> >>> ... The build system builds the plugins
> >>> properly and you can cross reference modem drivers from your modem
> >>> plugin without any problems.
> >>
> >>Simply refering to MBM driver from ste.c
> >>
> >one minor nitpick here. Can you please not squeeze this in between GPRS
> >and GPRS Context atoms. Put it at the same location the MBM plugin does.
> 
> Fixed.

patch has been applied. Thanks.

Regards

Marcel



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

* Re: [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-16 21:12       ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12         ` [PATCH v4 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 22:05         ` Marcel Holtmann
  1 sibling, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 22:05 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

>  Makefile.am                       |    3 +-
>  drivers/stemodem/radio-settings.c |  225 +++++++++++++++++++++++++++++++++++++
>  drivers/stemodem/stemodem.c       |    2 +
>  drivers/stemodem/stemodem.h       |    2 +
>  4 files changed, 231 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/stemodem/radio-settings.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index 16a3a3d..9462743 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -204,7 +204,8 @@ builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/stemodem/voicecall.c \
>  			drivers/stemodem/gprs-context.c \
>  			drivers/stemodem/caif_socket.h \
> -			drivers/stemodem/if_caif.h
> +			drivers/stemodem/if_caif.h \
> +			drivers/stemodem/radio-settings.c

please put it after or before the gprs-context.c. I wanna keep the atom
drivers together and not intermix with the CAIF includes.
 
>  builtin_modules += phonesim
>  builtin_sources += plugins/phonesim.c
> diff --git a/drivers/stemodem/radio-settings.c b/drivers/stemodem/radio-settings.c
> new file mode 100644
> index 0000000..49a7906
> --- /dev/null
> +++ b/drivers/stemodem/radio-settings.c
> @@ -0,0 +1,225 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
> + *  Copyright (C) 2010 ST-Ericsson AB.
> + *  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.
> + 

You need to put an empty line after your copyright. Please keep the
style we have for the copyright header.

> *
> + *  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 <config.h>
> +#endif
> +
> +#define _GNU_SOURCE
> +#include <string.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <errno.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/radio-settings.h>
> +
> +#include "gatchat.h"
> +#include "gatresult.h"
> +
> +#include "stemodem.h"
> +
> +static const char *none_prefix[] = { NULL };
> +static const char *cfun_prefix[] = { "+CFUN:", NULL };
> +
> +struct radio_settings_data {
> +	GAtChat *chat;
> +};
> +
> +enum ste_radio_mode {
> +	STE_RADIO_OFF = 0,
> +	STE_RADIO_ON = 1,
> +	STE_RADIO_FLIGHT_MODE = 4,
> +	STE_RADIO_GSM_ONLY = 5,
> +	STE_RADIO_WCDMA_ONLY = 6
> +};

Can you please insert tabs between the constant and the = <value>. We
prefer having the enums nicely tabbed.

> +static gboolean ste_mode_to_ofono_mode(enum ste_radio_mode stemode,
> +				enum ofono_radio_access_mode *mode)
> +{
> +	switch (stemode) {
> +	case STE_RADIO_ON:
> +		*mode = OFONO_RADIO_ACCESS_MODE_ANY;
> +		return TRUE;
> +	case STE_RADIO_GSM_ONLY:
> +		*mode = OFONO_RADIO_ACCESS_MODE_GSM;
> +		return TRUE;
> +	case STE_RADIO_WCDMA_ONLY:
> +		*mode = OFONO_RADIO_ACCESS_MODE_UMTS;
> +		return TRUE;
> +	default:
> +		return FALSE;
> +	}
> +}

I prefer that you leave out the default statement and just add a return
FALSE at the end of the function. Deal with missing enum entries and the
compiler complaining by just adding a break.

This has the advantage if you accidentally add a constant the compiler
will warn you instead of just using default statement.

> +static gboolean ofono_mode_to_ste_mode(enum ofono_radio_access_mode mode,
> +				enum ste_radio_mode *stemode)
> +{
> +	switch (mode) {
> +	case OFONO_RADIO_ACCESS_MODE_ANY:
> +		*stemode = STE_RADIO_ON;
> +		return TRUE;
> +	case OFONO_RADIO_ACCESS_MODE_GSM:
> +		*stemode = STE_RADIO_GSM_ONLY;
> +		return TRUE;
> +
> +	case OFONO_RADIO_ACCESS_MODE_UMTS:
> +		*stemode = STE_RADIO_WCDMA_ONLY;
> +		return TRUE;
> +	default:
> +		return FALSE;
> +	}
> +}

Same here. And in addition please remove the empty line in between that
is there for no real reason.

> +static void sterat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{

I prefer if you call this just rat_query_cb and don't bother prefixing
it with ste.

> +	struct cb_data *cbd = user_data;
> +	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
> +	enum ofono_radio_access_mode mode;
> +	struct ofono_error error;
> +	GAtResultIter iter;
> +	int value;
> +
> +	decode_at_error(&error, g_at_result_final_response(result));
> +
> +	if (!ok) {
> +		cb(&error, -1, cbd->data);
> +		return;
> +	}
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "+CFUN:"))
> +		goto err;
> +
> +	if (!g_at_result_iter_next_number(&iter, &value))
> +		goto err;
> +
> +	if (!ste_mode_to_ofono_mode(value, &mode))
> +		goto err;
> +
> +	CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
> +
> +	return;
> +
> +err:
> +	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
> +}
> +
> +static void ste_query_rat_mode(struct ofono_radio_settings *rs,
> +				ofono_radio_settings_rat_mode_query_cb_t cb,
> +				void *data)
> +{
> +	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
> +	struct cb_data *cbd = cb_data_new(cb, data);
> +
> +	if (g_at_chat_send(rsd->chat, "AT+CFUN?", cfun_prefix,
> +					sterat_query_cb, cbd, g_free) == 0) {
> +		CALLBACK_WITH_FAILURE(cb, -1, data);
> +		g_free(cbd);
> +	}
> +}
> +
> +static void sterat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{

Same here. Please call it rat_modify_cb.

> +	struct cb_data *cbd = user_data;
> +	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
> +	struct ofono_error error;
> +
> +	decode_at_error(&error, g_at_result_final_response(result));
> +
> +	if (!ok) {
> +		cb(&error, cbd->data);
> +		return;
> +	}
> +
> +	CALLBACK_WITH_SUCCESS(cb, cbd->data);
> +}
> +
> +static void ste_set_rat_mode(struct ofono_radio_settings *rs,
> +				enum ofono_radio_access_mode mode,
> +				ofono_radio_settings_rat_mode_set_cb_t cb,
> +				void *data)
> +{
> +	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
> +	struct cb_data *cbd = cb_data_new(cb, data);
> +	char buf[20];
> +	enum ste_radio_mode value;
> +
> +	if (!ofono_mode_to_ste_mode(mode, &value)) {
> +		CALLBACK_WITH_FAILURE(cb, data);
> +		g_free(cbd);
> +		return;
> +	}
> +
> +	snprintf(buf, sizeof(buf), "AT+CFUN=%u", value);
> +
> +	if (g_at_chat_send(rsd->chat, buf, none_prefix,
> +					sterat_modify_cb, cbd, g_free) == 0) {
> +		CALLBACK_WITH_FAILURE(cb, data);
> +		g_free(cbd);
> +	}
> +}
> +
> +static int ste_radio_settings_probe(struct ofono_radio_settings *rs,
> +					unsigned int vendor, void *data)
> +{
> +	GAtChat *chat = data;
> +	struct radio_settings_data *rsd;
> +	rsd = g_try_new0(struct radio_settings_data, 1);
> +	if (!rsd)
> +		return -ENOMEM;
> +
> +	rsd->chat = chat;
> +
> +	ofono_radio_settings_set_data(rs, rsd);
> +	ofono_radio_settings_register(rs);
> +
> +	return 0;
> +}
> +
> +static void ste_radio_settings_remove(struct ofono_radio_settings *rs)
> +{
> +	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
> +	ofono_radio_settings_set_data(rs, NULL);
> +	g_free(rsd);
> +}
> +
> +static struct ofono_radio_settings_driver driver = {
> +	.name			= "stemodem",
> +	.probe			= ste_radio_settings_probe,
> +	.remove		= ste_radio_settings_remove,
> +	.query_rat_mode	= ste_query_rat_mode,
> +	.set_rat_mode		= ste_set_rat_mode
> +};
> +
> +void ste_radio_settings_init()
> +{
> +	ofono_radio_settings_driver_register(&driver);
> +}
> +
> +void ste_radio_settings_exit()
> +{
> +	ofono_radio_settings_driver_unregister(&driver);
> +}
> diff --git a/drivers/stemodem/stemodem.c b/drivers/stemodem/stemodem.c
> index c18a8b5..ebc1c70 100644
> --- a/drivers/stemodem/stemodem.c
> +++ b/drivers/stemodem/stemodem.c
> @@ -38,6 +38,7 @@ static int stemodem_init(void)
>  {
>  	ste_voicecall_init();
>  	ste_gprs_context_init();
> +	ste_radio_settings_init();
>  
>  	return 0;
>  }
> @@ -46,6 +47,7 @@ static void stemodem_exit(void)
>  {
>  	ste_voicecall_exit();
>  	ste_gprs_context_exit();
> +	ste_radio_settings_exit();
>  }
>  
>  OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
> diff --git a/drivers/stemodem/stemodem.h b/drivers/stemodem/stemodem.h
> index 267e001..b1691a2 100644
> --- a/drivers/stemodem/stemodem.h
> +++ b/drivers/stemodem/stemodem.h
> @@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();
>  extern void ste_voicecall_init();
>  extern void ste_voicecall_exit();
>  
> +extern void ste_radio_settings_init();
> +extern void ste_radio_settings_exit();

Rest looks just fine to me.

Regards

Marcel



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

* Re: [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
  2010-08-16 21:12   ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12     ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 22:06     ` Marcel Holtmann
  1 sibling, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 22:06 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> ...
> >do we really wanna create another vendor quirk here. If both modems
> >behave identical then just pass OFONO_VENDOR_MBM in the SIM atom
> >registration and be done with it.
> 
> Re-use the MBM quirk rather than adding STE quirks in atmodem/sim.c
> 
> ---
>  plugins/ste.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/plugins/ste.c b/plugins/ste.c
> index 9cb49d3..9d9afd6 100644
> --- a/plugins/ste.c
> +++ b/plugins/ste.c
> @@ -214,7 +214,7 @@ static void ste_pre_sim(struct ofono_modem *modem)
>  
>  	ofono_devinfo_create(modem, 0, "atmodem", data->chat);
>  	sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
> -	ofono_voicecall_create(modem, 0, "stemodem", data->chat);
> +	ofono_voicecall_create(modem, OFONO_VENDOR_MBM, "stemodem", data->chat);

I still don't get it. The stemodem/voicecall.c doesn't use any quirks
and it should never do so. It is STE specific already.

Regards

Marcel




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

* Re: [PATCH v4 3/7] stemodem: Add polling for SIM ready.
  2010-08-16 21:12     ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12       ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 22:08       ` Marcel Holtmann
  1 sibling, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 22:08 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> Interim solution until support for SIM 'ready' notification is supported.
> ---
> Changes:
>  o Fixed style issues (tabs and newlines)
> 
>  plugins/ste.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 52 insertions(+), 3 deletions(-)
> 
> diff --git a/plugins/ste.c b/plugins/ste.c
> index f9875fd..5fecd5e 100644
> --- a/plugins/ste.c
> +++ b/plugins/ste.c
> @@ -60,8 +60,13 @@
>  #include <drivers/stemodem/caif_socket.h>
>  #include <drivers/stemodem/if_caif.h>
>  
> +static const char *cpin_prefix[] = { "+CPIN:", NULL };
> +
>  struct ste_data {
>  	GAtChat *chat;
> +	guint cpin_poll_source;
> +	guint cpin_poll_count;
> +	gboolean have_sim;
>  };
>  
>  static int ste_probe(struct ofono_modem *modem)
> @@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)
>  	ofono_modem_set_data(modem, NULL);
>  
>  	g_at_chat_unref(data->chat);
> +
> +	if (data->cpin_poll_source > 0)
> +		g_source_remove(data->cpin_poll_source);
> +
>  	g_free(data);
>  }
>  
> @@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)
>  	ofono_info("%s", str);
>  }
>  
> +static gboolean init_simpin_check(gpointer user_data);
> +
> +static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct ste_data *data = ofono_modem_get_data(modem);
> +
> +	/* Modem returns +CME ERROR: 10 if SIM is not ready. */
> +	if (!ok && result->final_or_pdu &&
> +			!strcmp(result->final_or_pdu, "+CME ERROR: 10") &&
> +			data->cpin_poll_count++ < 5) {
> +		data->cpin_poll_source =
> +			g_timeout_add_seconds(1, init_simpin_check, modem);
> +		return;
> +	}
> +
> +	data->cpin_poll_count = 0;
> +
> +	/* Modem returns ERROR if there is no SIM in slot. */
> +	data->have_sim = ok;
> +
> +	ofono_modem_set_powered(modem, TRUE);
> +}
> +
> +static gboolean init_simpin_check(gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct ste_data *data = ofono_modem_get_data(modem);
> +
> +	data->cpin_poll_source = 0;
> +
> +	g_at_chat_send(data->chat, "AT+CPIN?", cpin_prefix,
> +			simpin_check, modem, NULL);
> +
> +	return FALSE;
> +}
> +
>  static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
>  {
>  	struct ofono_modem *modem = user_data;
>  
>  	DBG("");
>  
> -	if (!ok)
> +	if (!ok) {
>  		ofono_modem_set_powered(modem, FALSE);
> +		return;
> +	}
>  
> -	ofono_modem_set_powered(modem, TRUE);
> +	init_simpin_check(modem);
>  }

I am fine with this if Denis is as well.
 
>  static int ste_enable(struct ofono_modem *modem)
> @@ -168,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)
>  	if (getenv("OFONO_AT_DEBUG"))
>  		g_at_chat_set_debug(data->chat, ste_debug, NULL);
>  
> -	g_at_chat_send(data->chat, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
> +	g_at_chat_send(data->chat, "AT&F E0 V1 X4 &C1 +CMEE=1",
> +			NULL, NULL, NULL, NULL);
>  	g_at_chat_send(data->chat, "AT+CFUN=1", NULL, cfun_enable, modem, NULL);

Why this change? If so, it does not belong in this commit. Or you need
to add a comment why it does indeed.

Regards

Marcel



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

* Re: [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface
  2010-08-16 21:12           ` [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-16 21:12             ` [PATCH v4 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 22:11             ` Marcel Holtmann
  1 sibling, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 22:11 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> CAIF in Linux kernel 2.6.35 must use RTNL for configuring
> CAIF interfaces.
> ---
>  drivers/stemodem/gprs-context.c |   51 +++++--
>  drivers/stemodem/rtnl.c         |  318 +++++++++++++++++++++++++++++++++++++++
>  drivers/stemodem/rtnl.h         |   24 +++
>  3 files changed, 380 insertions(+), 13 deletions(-)
>  create mode 100644 drivers/stemodem/rtnl.c
>  create mode 100644 drivers/stemodem/rtnl.h

I can't really let you do make blocking reads to the netlink socket.
That would be pretty much a bad idea.

We need a better solution for this. Maybe one that also helps the ISI
modem drivers.

Regards

Marcel



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

* Re: [PATCH v4 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
  2010-08-16 21:12             ` [PATCH v4 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-16 22:12               ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-16 22:12 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

>  plugins/modem.conf  |    5 +++++
>  plugins/modemconf.c |    1 +
>  plugins/ste.c       |   20 +++++++++++++++++++-
>  3 files changed, 25 insertions(+), 1 deletions(-)

please don't intermix modemconf and STE plugin changes. I need two
separate patches for this.

Regards

Marcel



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

* [PATCH v5 0/8] Resubmitting STE Driver Patches.
  2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                   ` (8 preceding siblings ...)
  2010-08-16 21:12 ` [PATCH v4 " Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:22   ` [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (7 more replies)
  9 siblings, 8 replies; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

Resubmitting same changes as last patch set, but
some of the patches are split up in smaller parts.
The RTNL patch is removed and replaced by a separate RFC.

Sjur Brændeland (8):
  plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
  stemodem: Add polling for SIM ready.
  plugins/ste: Add AT Channel configurations (new)
  stemodem: Add Radio Settings to STE Modem
  plugins/ste: Add Radio-Settings
  plugins/modemconf.c add support for Interface for STE plugin. (new)
  plugins/ste: Use SOCK_STREAM for CAIF and enable interface
    specification.
  plugins: Add STE sample to modem.conf (new)

 Makefile.am                       |    2 +
 drivers/stemodem/radio-settings.c |  225 +++++++++++++++++++++++++++++++++++++
 drivers/stemodem/stemodem.c       |    2 +
 drivers/stemodem/stemodem.h       |    2 +
 plugins/modem.conf                |    5 +
 plugins/modemconf.c               |    1 +
 plugins/ste.c                     |   79 ++++++++++++-
 7 files changed, 311 insertions(+), 5 deletions(-)
 create mode 100644 drivers/stemodem/radio-settings.c


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

* [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:43     ` Marcel Holtmann
  2010-08-17 12:22   ` [PATCH v5 2/8] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (6 subsequent siblings)
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

---
 Change: This time the right line is hopefully being edited.

 plugins/ste.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 5b34704..ef375ea 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -213,7 +213,7 @@ static void ste_pre_sim(struct ofono_modem *modem)
 	DBG("%p", modem);
 
 	ofono_devinfo_create(modem, 0, "atmodem", data->chat);
-	sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
+	sim = ofono_sim_create(modem, OFONO_VENDOR_MBM, "atmodem", data->chat);
 	ofono_voicecall_create(modem, 0, "stemodem", data->chat);
 
 	if (sim)
-- 
1.6.3.3


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

* [PATCH v5 2/8] stemodem: Add polling for SIM ready.
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:22   ` [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:58     ` Marcel Holtmann
  2010-08-17 12:22   ` [PATCH v5 3/8] plugins/ste: Add AT Channel configurations Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (5 subsequent siblings)
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

Interim solution until support for SIM 'ready' notification is supported.
---
Change: AT-channel configuration is moved to separate patch.

 plugins/ste.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index ef375ea..fcf4d15 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -60,8 +60,13 @@
 #include <drivers/stemodem/caif_socket.h>
 #include <drivers/stemodem/if_caif.h>
 
+static const char *cpin_prefix[] = { "+CPIN:", NULL };
+
 struct ste_data {
 	GAtChat *chat;
+	guint cpin_poll_source;
+	guint cpin_poll_count;
+	gboolean have_sim;
 };
 
 static int ste_probe(struct ofono_modem *modem)
@@ -88,6 +93,10 @@ static void ste_remove(struct ofono_modem *modem)
 	ofono_modem_set_data(modem, NULL);
 
 	g_at_chat_unref(data->chat);
+
+	if (data->cpin_poll_source > 0)
+		g_source_remove(data->cpin_poll_source);
+
 	g_free(data);
 }
 
@@ -96,16 +105,55 @@ static void ste_debug(const char *str, void *user_data)
 	ofono_info("%s", str);
 }
 
+static gboolean init_simpin_check(gpointer user_data);
+
+static void simpin_check(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	/* Modem returns +CME ERROR: 10 if SIM is not ready. */
+	if (!ok && result->final_or_pdu &&
+			!strcmp(result->final_or_pdu, "+CME ERROR: 10") &&
+			data->cpin_poll_count++ < 5) {
+		data->cpin_poll_source =
+			g_timeout_add_seconds(1, init_simpin_check, modem);
+		return;
+	}
+
+	data->cpin_poll_count = 0;
+
+	/* Modem returns ERROR if there is no SIM in slot. */
+	data->have_sim = ok;
+
+	ofono_modem_set_powered(modem, TRUE);
+}
+
+static gboolean init_simpin_check(gpointer user_data)
+{
+	struct ofono_modem *modem = user_data;
+	struct ste_data *data = ofono_modem_get_data(modem);
+
+	data->cpin_poll_source = 0;
+
+	g_at_chat_send(data->chat, "AT+CPIN?", cpin_prefix,
+			simpin_check, modem, NULL);
+
+	return FALSE;
+}
+
 static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_modem *modem = user_data;
 
 	DBG("");
 
-	if (!ok)
+	if (!ok) {
 		ofono_modem_set_powered(modem, FALSE);
+		return;
+	}
 
-	ofono_modem_set_powered(modem, TRUE);
+	init_simpin_check(modem);
 }
 
 static int ste_enable(struct ofono_modem *modem)
-- 
1.6.3.3


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

* [PATCH v5 3/8] plugins/ste: Add AT Channel configurations
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:22   ` [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:22   ` [PATCH v5 2/8] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:43     ` Marcel Holtmann
  2010-08-17 12:22   ` [PATCH v5 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (4 subsequent siblings)
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

---
 plugins/ste.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index fcf4d15..bcf2704 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -216,7 +216,8 @@ static int ste_enable(struct ofono_modem *modem)
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(data->chat, ste_debug, NULL);
 
-	g_at_chat_send(data->chat, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL);
+	g_at_chat_send(data->chat, "AT&F E0 V1 X4 &C1 +CMEE=1",
+			NULL, NULL, NULL, NULL);
 	g_at_chat_send(data->chat, "AT+CFUN=1", NULL, cfun_enable, modem, NULL);
 
 	return -EINPROGRESS;
-- 
1.6.3.3


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

* [PATCH v5 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (2 preceding siblings ...)
  2010-08-17 12:22   ` [PATCH v5 3/8] plugins/ste: Add AT Channel configurations Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:43     ` Marcel Holtmann
  2010-08-17 12:22   ` [PATCH v5 5/8] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (3 subsequent siblings)
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

---
Changes:
o Changed order of files in Makefile
o Fixed missing empty line in copyright
o Formatted enum better
o Removed default is switches
o Removed ste in function names

 Makefile.am                       |    2 +
 drivers/stemodem/radio-settings.c |  230 +++++++++++++++++++++++++++++++++++++
 drivers/stemodem/stemodem.c       |    2 +
 drivers/stemodem/stemodem.h       |    2 +
 4 files changed, 236 insertions(+), 0 deletions(-)
 create mode 100644 drivers/stemodem/radio-settings.c

diff --git a/Makefile.am b/Makefile.am
index 16a3a3d..d8f36f2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -202,10 +202,12 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/stemodem/stemodem.h \
 			drivers/stemodem/stemodem.c \
 			drivers/stemodem/voicecall.c \
+			drivers/stemodem/radio-settings.c \
 			drivers/stemodem/gprs-context.c \
 			drivers/stemodem/caif_socket.h \
 			drivers/stemodem/if_caif.h
 
+
 builtin_modules += phonesim
 builtin_sources += plugins/phonesim.c
 
diff --git a/drivers/stemodem/radio-settings.c b/drivers/stemodem/radio-settings.c
new file mode 100644
index 0000000..9f93695
--- /dev/null
+++ b/drivers/stemodem/radio-settings.c
@@ -0,0 +1,230 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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 <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/radio-settings.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "stemodem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { "+CFUN:", NULL };
+
+struct radio_settings_data {
+	GAtChat *chat;
+};
+
+enum ste_radio_mode {
+	STE_RADIO_OFF =	0,
+	STE_RADIO_ON =		1,
+	STE_RADIO_FLIGHT_MODE = 4,
+	STE_RADIO_GSM_ONLY =	5,
+	STE_RADIO_WCDMA_ONLY =	6
+};
+
+static gboolean ste_mode_to_ofono_mode(enum ste_radio_mode stemode,
+				enum ofono_radio_access_mode *mode)
+{
+	switch (stemode) {
+	case STE_RADIO_ON:
+		*mode = OFONO_RADIO_ACCESS_MODE_ANY;
+		return TRUE;
+	case STE_RADIO_GSM_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_GSM;
+		return TRUE;
+	case STE_RADIO_WCDMA_ONLY:
+		*mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+		return TRUE;
+	case STE_RADIO_OFF:
+	case STE_RADIO_FLIGHT_MODE:
+		break;
+	}
+
+	return FALSE;
+}
+
+static gboolean ofono_mode_to_ste_mode(enum ofono_radio_access_mode mode,
+				enum ste_radio_mode *stemode)
+{
+	switch (mode) {
+	case OFONO_RADIO_ACCESS_MODE_ANY:
+		*stemode = STE_RADIO_ON;
+		return TRUE;
+	case OFONO_RADIO_ACCESS_MODE_GSM:
+		*stemode = STE_RADIO_GSM_ONLY;
+		return TRUE;
+	case OFONO_RADIO_ACCESS_MODE_UMTS:
+		*stemode = STE_RADIO_WCDMA_ONLY;
+		return TRUE;
+	case OFONO_RADIO_ACCESS_MODE_LTE:
+		break;
+	}
+
+	return FALSE;
+}
+
+static void rat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_query_cb_t cb = cbd->cb;
+	enum ofono_radio_access_mode mode;
+	struct ofono_error error;
+	GAtResultIter iter;
+	int value;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "+CFUN:"))
+		goto err;
+
+	if (!g_at_result_iter_next_number(&iter, &value))
+		goto err;
+
+	if (!ste_mode_to_ofono_mode(value, &mode))
+		goto err;
+
+	CALLBACK_WITH_SUCCESS(cb, mode, cbd->data);
+
+	return;
+
+err:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void ste_query_rat_mode(struct ofono_radio_settings *rs,
+				ofono_radio_settings_rat_mode_query_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(rsd->chat, "AT+CFUN?", cfun_prefix,
+					rat_query_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, -1, data);
+		g_free(cbd);
+	}
+}
+
+static void rat_modify_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_radio_settings_rat_mode_set_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, cbd->data);
+		return;
+	}
+
+	CALLBACK_WITH_SUCCESS(cb, cbd->data);
+}
+
+static void ste_set_rat_mode(struct ofono_radio_settings *rs,
+				enum ofono_radio_access_mode mode,
+				ofono_radio_settings_rat_mode_set_cb_t cb,
+				void *data)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[20];
+	enum ste_radio_mode value;
+
+	if (!ofono_mode_to_ste_mode(mode, &value)) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+		return;
+	}
+
+	snprintf(buf, sizeof(buf), "AT+CFUN=%u", value);
+
+	if (g_at_chat_send(rsd->chat, buf, none_prefix,
+					rat_modify_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, data);
+		g_free(cbd);
+	}
+}
+
+static int ste_radio_settings_probe(struct ofono_radio_settings *rs,
+					unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct radio_settings_data *rsd;
+	rsd = g_try_new0(struct radio_settings_data, 1);
+	if (!rsd)
+		return -ENOMEM;
+
+	rsd->chat = chat;
+
+	ofono_radio_settings_set_data(rs, rsd);
+	ofono_radio_settings_register(rs);
+
+	return 0;
+}
+
+static void ste_radio_settings_remove(struct ofono_radio_settings *rs)
+{
+	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
+	ofono_radio_settings_set_data(rs, NULL);
+	g_free(rsd);
+}
+
+static struct ofono_radio_settings_driver driver = {
+	.name			= "stemodem",
+	.probe			= ste_radio_settings_probe,
+	.remove		= ste_radio_settings_remove,
+	.query_rat_mode	= ste_query_rat_mode,
+	.set_rat_mode		= ste_set_rat_mode
+};
+
+void ste_radio_settings_init()
+{
+	ofono_radio_settings_driver_register(&driver);
+}
+
+void ste_radio_settings_exit()
+{
+	ofono_radio_settings_driver_unregister(&driver);
+}
diff --git a/drivers/stemodem/stemodem.c b/drivers/stemodem/stemodem.c
index c18a8b5..ebc1c70 100644
--- a/drivers/stemodem/stemodem.c
+++ b/drivers/stemodem/stemodem.c
@@ -38,6 +38,7 @@ static int stemodem_init(void)
 {
 	ste_voicecall_init();
 	ste_gprs_context_init();
+	ste_radio_settings_init();
 
 	return 0;
 }
@@ -46,6 +47,7 @@ static void stemodem_exit(void)
 {
 	ste_voicecall_exit();
 	ste_gprs_context_exit();
+	ste_radio_settings_exit();
 }
 
 OFONO_PLUGIN_DEFINE(stemodem, "STE modem driver", VERSION,
diff --git a/drivers/stemodem/stemodem.h b/drivers/stemodem/stemodem.h
index 267e001..b1691a2 100644
--- a/drivers/stemodem/stemodem.h
+++ b/drivers/stemodem/stemodem.h
@@ -28,3 +28,5 @@ extern void ste_gprs_context_exit();
 extern void ste_voicecall_init();
 extern void ste_voicecall_exit();
 
+extern void ste_radio_settings_init();
+extern void ste_radio_settings_exit();
-- 
1.6.3.3


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

* [PATCH v5 5/8] plugins/ste: Add Radio-Settings
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (3 preceding siblings ...)
  2010-08-17 12:22   ` [PATCH v5 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:43     ` Marcel Holtmann
  2010-08-17 12:22   ` [PATCH v5 6/8] plugins/modemconf.c add support for Interface for STE plugin Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (2 subsequent siblings)
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

---
 drivers/stemodem/radio-settings.c |    5 +++++
 plugins/ste.c                     |    2 ++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index bcf2704..16ddbe1 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -54,6 +54,7 @@
 #include <ofono/voicecall.h>
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
+#include <ofono/radio-settings.h>
 #include <ofono/stk.h>
 #include <drivers/atmodem/vendor.h>
 
@@ -279,6 +280,7 @@ static void ste_post_sim(struct ofono_modem *modem)
 	DBG("%p", modem);
 
 	ofono_stk_create(modem, 0, "mbmmodem", data->chat);
+	ofono_radio_settings_create(modem, 0, "stemodem", data->chat);
 	ofono_ussd_create(modem, 0, "atmodem", data->chat);
 	ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
 	ofono_call_settings_create(modem, 0, "atmodem", data->chat);
-- 
1.6.3.3


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

* [PATCH v5 6/8] plugins/modemconf.c add support for Interface for STE plugin.
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (4 preceding siblings ...)
  2010-08-17 12:22   ` [PATCH v5 5/8] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:51     ` Marcel Holtmann
  2010-08-17 12:22   ` [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:22   ` [PATCH v5 8/8] plugins: Add STE sample to modem.conf Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

---
 plugins/modemconf.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 3747cd9..d7b1354 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -138,6 +138,7 @@ static struct {
 	{ "g1",		set_device	},
 	{ "wavecom",	set_device	},
 	{ "ste",	set_device	},
+	{ "ste",	set_interface	},
 	{ "calypso",	set_device	},
 	{ "palmpre",	set_device	},
 	{ "isimodem",	set_interface	},
-- 
1.6.3.3


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

* [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (5 preceding siblings ...)
  2010-08-17 12:22   ` [PATCH v5 6/8] plugins/modemconf.c add support for Interface for STE plugin Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:46     ` Marcel Holtmann
  2010-08-17 12:22   ` [PATCH v5 8/8] plugins: Add STE sample to modem.conf Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

---
 plugins/ste.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 16ddbe1..479d85c 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <net/if.h>
 
 #include <glib.h>
 #include <gatchat.h>
@@ -171,14 +172,31 @@ static int ste_enable(struct ofono_modem *modem)
 	if (!device) {
 		struct sockaddr_caif addr;
 		int err;
+		const char *interface;
 
 		/* Create a CAIF socket for AT Service */
-		fd = socket(AF_CAIF, SOCK_SEQPACKET, CAIFPROTO_AT);
+		fd = socket(AF_CAIF, SOCK_STREAM, CAIFPROTO_AT);
 		if (fd < 0) {
 			ofono_error("Failed to create CAIF socket for AT");
 			return -EIO;
 		}
 
+		/* Bind CAIF socket to specified interface */
+		interface = ofono_modem_get_string(modem, "Interface");
+		if (interface) {
+			struct ifreq ifreq;
+			memset(&ifreq, 0, sizeof(ifreq));
+			strcpy(ifreq.ifr_name, interface);
+			err = setsockopt(fd, SOL_SOCKET,
+					SO_BINDTODEVICE, &ifreq, sizeof(ifreq));
+			if (err < 0) {
+				ofono_error("Failed to bind caif socket "
+					"to interface");
+				close(fd);
+				return err;
+			}
+		}
+
 		memset(&addr, 0, sizeof(addr));
 		addr.family = AF_CAIF;
 		addr.u.at.type = CAIF_ATTYPE_PLAIN;
-- 
1.6.3.3


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

* [PATCH v5 8/8] plugins: Add STE sample to modem.conf
  2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
                     ` (6 preceding siblings ...)
  2010-08-17 12:22   ` [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:22   ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
  2010-08-17 12:51     ` Marcel Holtmann
  7 siblings, 1 reply; 53+ messages in thread
From: Sjur =?unknown-8bit?q?Br=C3=A6ndeland?= @ 2010-08-17 12:22 UTC (permalink / raw)
  To: ofono

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

---
 plugins/modem.conf |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/plugins/modem.conf b/plugins/modem.conf
index 66bf932..b577114 100644
--- a/plugins/modem.conf
+++ b/plugins/modem.conf
@@ -44,3 +44,8 @@
 #[n900]
 #Driver=n900modem
 #Interface=phonet0
+
+# Sample STE modem
+#[ste]
+#Interface=cfttyS0
+#Driver=ste
-- 
1.6.3.3


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

* Re: [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks.
  2010-08-17 12:22   ` [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:43     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:43 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> ---
>  Change: This time the right line is hopefully being edited.
> 
>  plugins/ste.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

patch has been applied. Thanks.

Regards

Marcel



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

* Re: [PATCH v5 5/8] plugins/ste: Add Radio-Settings
  2010-08-17 12:22   ` [PATCH v5 5/8] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:43     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:43 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> ---
>  drivers/stemodem/radio-settings.c |    5 +++++
>  plugins/ste.c                     |    2 ++
>  2 files changed, 7 insertions(+), 0 deletions(-)

your diffstat is wrong here. Please check the tools you use to create
them.

Patch has been applied.

Regards

Marcel



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

* Re: [PATCH v5 4/7] stemodem: Add Radio Settings to STE Modem
  2010-08-17 12:22   ` [PATCH v5 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:43     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:43 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> ---
> Changes:
> o Changed order of files in Makefile
> o Fixed missing empty line in copyright
> o Formatted enum better
> o Removed default is switches
> o Removed ste in function names
> 
>  Makefile.am                       |    2 +
>  drivers/stemodem/radio-settings.c |  230 +++++++++++++++++++++++++++++++++++++
>  drivers/stemodem/stemodem.c       |    2 +
>  drivers/stemodem/stemodem.h       |    2 +
>  4 files changed, 236 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/stemodem/radio-settings.c

patch has been applied.

> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -202,10 +202,12 @@ builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/stemodem/stemodem.h \
>  			drivers/stemodem/stemodem.c \
>  			drivers/stemodem/voicecall.c \
> +			drivers/stemodem/radio-settings.c \
>  			drivers/stemodem/gprs-context.c \
>  			drivers/stemodem/caif_socket.h \
>  			drivers/stemodem/if_caif.h
>  
> +
>  builtin_modules += phonesim
>  builtin_sources += plugins/phonesim.c

I fixed this for you, but in the future, please don't add extra unneeded
empty lines.

Regards

Marcel



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

* Re: [PATCH v5 3/8] plugins/ste: Add AT Channel configurations
  2010-08-17 12:22   ` [PATCH v5 3/8] plugins/ste: Add AT Channel configurations Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:43     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:43 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> ---
>  plugins/ste.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)

patch has been applied. Thanks.

Regards

Marcel



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

* Re: [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification.
  2010-08-17 12:22   ` [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:46     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:46 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> ---
>  plugins/ste.c |   20 +++++++++++++++++++-
>  1 files changed, 19 insertions(+), 1 deletions(-)

patch has been applied. Thanks.

Regards

Marcel



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

* Re: [PATCH v5 6/8] plugins/modemconf.c add support for Interface for STE plugin.
  2010-08-17 12:22   ` [PATCH v5 6/8] plugins/modemconf.c add support for Interface for STE plugin Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:51     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:51 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

>  plugins/modemconf.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/plugins/modemconf.c b/plugins/modemconf.c
> index 3747cd9..d7b1354 100644
> --- a/plugins/modemconf.c
> +++ b/plugins/modemconf.c
> @@ -138,6 +138,7 @@ static struct {
>  	{ "g1",		set_device	},
>  	{ "wavecom",	set_device	},
>  	{ "ste",	set_device	},
> +	{ "ste",	set_interface	},
>  	{ "calypso",	set_device	},
>  	{ "palmpre",	set_device	},
>  	{ "isimodem",	set_interface	},

I applied this patch, but keep in mind that modemconf will go away
pretty soon.

Regards

Marcel



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

* Re: [PATCH v5 8/8] plugins: Add STE sample to modem.conf
  2010-08-17 12:22   ` [PATCH v5 8/8] plugins: Add STE sample to modem.conf Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:51     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:51 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

>  plugins/modem.conf |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)

patch has been applied. Thanks.

Regards

Marcel



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

* Re: [PATCH v5 2/8] stemodem: Add polling for SIM ready.
  2010-08-17 12:22   ` [PATCH v5 2/8] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
@ 2010-08-17 12:58     ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2010-08-17 12:58 UTC (permalink / raw)
  To: ofono

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

Hi Sjur,

> Interim solution until support for SIM 'ready' notification is supported.
> ---
> Change: AT-channel configuration is moved to separate patch.
> 
>  plugins/ste.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 50 insertions(+), 2 deletions(-)

patch has been applied.

Denis, if you don't like it then feel free to revert it. For me it
looked fine until we have better solution for this.

Regards

Marcel



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

end of thread, other threads:[~2010-08-17 12:58 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16 13:54 [PATCHv2 0/7] Resubmitting STE Driver patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 13:54 ` [PATCHv2 1/7] stemodem: Add support for STK by including MBM implementation Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 14:01   ` Marcel Holtmann
2010-08-16 16:21     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 13:54 ` [PATCHv2 2/7] atmodem: Enable STE usage of AT*EPEV and AT*EPEE for PIN handling Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 14:03   ` Marcel Holtmann
2010-08-16 13:54 ` [PATCHv2 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 13:54 ` [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 14:05   ` Marcel Holtmann
2010-08-16 16:29     ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 16:36       ` Marcel Holtmann
2010-08-16 13:54 ` [PATCHv2 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 13:54 ` [PATCHv2 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 13:54 ` [PATCHv2 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:35 ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:35   ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:35     ` [PATCH v3 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:35       ` [PATCH v3 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:35         ` [PATCH v3 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:35           ` [PATCH v3 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:35             ` [PATCH v3 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 20:45     ` [PATCH v3 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Marcel Holtmann
2010-08-16 20:44   ` [PATCH v3 1/7] plugins/ste: Include STK support from MBM driver Marcel Holtmann
2010-08-16 21:12 ` [PATCH v4 " Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 21:12   ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 21:12     ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 21:12       ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 21:12         ` [PATCH v4 5/7] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 21:12           ` [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 21:12             ` [PATCH v4 7/7] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-16 22:12               ` Marcel Holtmann
2010-08-16 22:11             ` [PATCH v4 6/7] stemodem: Use RTNL for creating CAIF interface Marcel Holtmann
2010-08-16 22:05         ` [PATCH v4 4/7] stemodem: Add Radio Settings to STE Modem Marcel Holtmann
2010-08-16 22:08       ` [PATCH v4 3/7] stemodem: Add polling for SIM ready Marcel Holtmann
2010-08-16 22:06     ` [PATCH v4 2/7] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Marcel Holtmann
2010-08-16 21:58   ` [PATCH v4 1/7] plugins/ste: Include STK support from MBM driver Marcel Holtmann
2010-08-17 12:22 ` [PATCH v5 0/8] Resubmitting STE Driver Patches Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:22   ` [PATCH v5 1/8] plugins/ste: SIM - STE registers as MBM to utilize mbm quirks Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:43     ` Marcel Holtmann
2010-08-17 12:22   ` [PATCH v5 2/8] stemodem: Add polling for SIM ready Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:58     ` Marcel Holtmann
2010-08-17 12:22   ` [PATCH v5 3/8] plugins/ste: Add AT Channel configurations Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:43     ` Marcel Holtmann
2010-08-17 12:22   ` [PATCH v5 4/7] stemodem: Add Radio Settings to STE Modem Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:43     ` Marcel Holtmann
2010-08-17 12:22   ` [PATCH v5 5/8] plugins/ste: Add Radio-Settings Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:43     ` Marcel Holtmann
2010-08-17 12:22   ` [PATCH v5 6/8] plugins/modemconf.c add support for Interface for STE plugin Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:51     ` Marcel Holtmann
2010-08-17 12:22   ` [PATCH v5 7/8] plugins/ste: Use SOCK_STREAM for CAIF and enable interface specification Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:46     ` Marcel Holtmann
2010-08-17 12:22   ` [PATCH v5 8/8] plugins: Add STE sample to modem.conf Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-08-17 12:51     ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox