Discussion:
[PATCH 0/1] Re: huawei: network attachment unstability
Christophe Ronco
2018-10-24 15:09:13 UTC
Permalink
I made a patch that fix the problem I see.
The idea is to force a detach only if:
- we are attached and powered == False
- we are roaming and RoamingAllowed = False

I have tested my use case (loosing network when switching from WCDMA to LTE)
and it is fixed.
I have tested to set RoamingAllowed to false and back to true while roaming.
Detach is forced (AT+CGATT=0) when RoamingAllowed is set to false and
AT+CGATT=1 is sent when RoamingAllowed is set back to true.

Christophe Ronco (1):
gprs: detach from network only if needed

src/gprs.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
--
2.7.4
Christophe Ronco
2018-10-24 15:09:14 UTC
Permalink
With some huawei USB keys (E3372, MS2372h), when switching from WCDMA to
LTE network, a network attachment loss is reported during a short time.
Forcing data detach in this case is a bad idea. Consequences can be a loop
like that:
t0) Attached to WCDMA network
t1) Switch to LTE network
t1+xs) Attachment loss reported
t1+(x+2)s) Attached to WCDMA network
t2) Switch to LTE network
t2) Attachment loss reported
t2+2s) Attached to WCDMA network

With this patch we force gprs detach only if unpowered or roaming while
roaming is not allowed. We don't force gprs detach if we loose network.
---
src/gprs.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index edd17f2..320505a 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1676,15 +1676,24 @@ static void gprs_netreg_removed(struct ofono_gprs *gprs)
static void gprs_netreg_update(struct ofono_gprs *gprs)
{
ofono_bool_t attach;
+ ofono_bool_t force_detach;
+
+ DBG("netreg:%u, powered:%u, roaming_allowed:%u, driver_attached:%u",
+ gprs->netreg_status, gprs->powered,
+ gprs->roaming_allowed, gprs->driver_attached);

attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED;
+ attach |= gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING;

- attach = attach || (gprs->roaming_allowed &&
- gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING);
+ if (!attach)
+ return;

- attach = attach && gprs->powered;
+ force_detach = !gprs->powered || (!gprs->roaming_allowed &&
+ gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING);

- DBG("attach: %u, driver_attached: %u", attach, gprs->driver_attached);
+ if ((force_detach && !gprs->driver_attached) ||
+ (!force_detach && gprs->driver_attached))
+ return;

if (ofono_netreg_get_technology(gprs->netreg) ==
ACCESS_TECHNOLOGY_EUTRAN && have_read_settings(gprs))
@@ -1692,9 +1701,6 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
* For LTE we set attached status only on successful
* context activation.
*/
- return;
-
- if (gprs->driver_attached == attach)
return;

if (gprs->flags & GPRS_FLAG_ATTACHING) {
@@ -1703,9 +1709,9 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
}

gprs->flags |= GPRS_FLAG_ATTACHING;
-
- gprs->driver_attached = attach;
- gprs->driver->set_attached(gprs, attach, gprs_attach_callback, gprs);
+ gprs->driver_attached = !gprs->driver_attached;
+ gprs->driver->set_attached(gprs, gprs->driver_attached,
+ gprs_attach_callback, gprs);
}

static void netreg_status_changed(int status, int lac, int ci, int tech,
--
2.7.4
Denis Kenzior
2018-10-25 02:45:00 UTC
Permalink
Hi Christophe,
Post by Christophe Ronco
With some huawei USB keys (E3372, MS2372h), when switching from WCDMA to
LTE network, a network attachment loss is reported during a short time.
Forcing data detach in this case is a bad idea. Consequences can be a loop
t0) Attached to WCDMA network
t1) Switch to LTE network
t1+xs) Attachment loss reported
t1+(x+2)s) Attached to WCDMA network
t2) Switch to LTE network
t2) Attachment loss reported
t2+2s) Attached to WCDMA network
So LTE is weird. For some reason 3GPP decided to have +CGATT control
attach procedures even for LTE, which honestly makes no sense to me, but
what can you do..

So yes, I agree the current behavior needs to be fixed, the tricky part
is how...
Post by Christophe Ronco
With this patch we force gprs detach only if unpowered or roaming while
roaming is not allowed. We don't force gprs detach if we loose network.
And herein lies the issue. For UMTS/GSM the whole point of oFono
behavior was to not even attach to PS while roaming as that would incur
roaming charges. So oFono has to control the attach status (as that is
what 27.007 intended anyway). However, many vendors (particularly with
data-only modules) went in the direction of always auto-attaching to PS
without having any way to control that behavior. Hence oFono uses a
rather large hammer and detaches on every registration loss.

The whole 'roaming charges while attached to PS' may now be a purely
historical oddity, I really don't know. But it does lead to a weird
side-effect where RoamingAllowed=False could result in oFono forcing a
detach on PS and thus the modem never switching over to LTE as a result.

So the ideal situation would be to turn all this off for LTE based
dongles, have the ability to tell the modem not to auto-attach on 3G/2G,
and maybe even attach only controlling 3G/2G PS domain only, not LTE.
Post by Christophe Ronco
---
src/gprs.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index edd17f2..320505a 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1676,15 +1676,24 @@ static void gprs_netreg_removed(struct ofono_gprs *gprs)
static void gprs_netreg_update(struct ofono_gprs *gprs)
{
ofono_bool_t attach;
+ ofono_bool_t force_detach;
+
+ DBG("netreg:%u, powered:%u, roaming_allowed:%u, driver_attached:%u",
+ gprs->netreg_status, gprs->powered,
+ gprs->roaming_allowed, gprs->driver_attached);
attach = gprs->netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED;
+ attach |= gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING;
- attach = attach || (gprs->roaming_allowed &&
- gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING);
+ if (!attach)
+ return;
- attach = attach && gprs->powered;
+ force_detach = !gprs->powered || (!gprs->roaming_allowed &&
+ gprs->netreg_status == NETWORK_REGISTRATION_STATUS_ROAMING);
See above. You're going from 'oFono controls attach' to 'modem controls
attach and we only detach if needed' This is a fairly major behavioral
change, so we may want to start in a bit less drastic way...
Post by Christophe Ronco
- DBG("attach: %u, driver_attached: %u", attach, gprs->driver_attached);
+ if ((force_detach && !gprs->driver_attached) ||
+ (!force_detach && gprs->driver_attached))
+ return;
if (ofono_netreg_get_technology(gprs->netreg) ==
ACCESS_TECHNOLOGY_EUTRAN && have_read_settings(gprs))
@@ -1692,9 +1701,6 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
* For LTE we set attached status only on successful
* context activation.
*/
- return;
-
- if (gprs->driver_attached == attach)
return;
if (gprs->flags & GPRS_FLAG_ATTACHING) {
@@ -1703,9 +1709,9 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
}
gprs->flags |= GPRS_FLAG_ATTACHING;
-
- gprs->driver_attached = attach;
- gprs->driver->set_attached(gprs, attach, gprs_attach_callback, gprs);
+ gprs->driver_attached = !gprs->driver_attached;
+ gprs->driver->set_attached(gprs, gprs->driver_attached,
+ gprs_attach_callback, gprs);
}
static void netreg_status_changed(int status, int lac, int ci, int tech,
Regards,
-Denis
Denis Kenzior
2018-10-25 03:15:24 UTC
Permalink
Hi Giacinto,
Hi Denis,
Post by Denis Kenzior
So the ideal situation would be to turn all this off for LTE based
dongles, have the ability to tell the modem not to auto-attach on 3G/2G,
and maybe even attach only controlling 3G/2G PS domain only, not LTE.
this is not possible, and there are all the Hand-over scenarios, for
example during a CSFB call, or loss of LTE coverage.
What exactly is impossible? a CSFB call goes onto the CS domain, so
there should be no problem going from LTE -> CS only, no?
It seems strange how LTE works because it is often overlooked that it
is just the GPRS part of 2G/3G,
with a small difference at the registration phase, which also performs
the attach (hence it is called combined attach).
Yes, but roaming is also completely different with LTE and many of these
weird historical billing quirks no longer apply.
Maybe it is really worth to start an ofono 2.x branch and remove this
roaming control on the attach.
Perhaps, but I wouldn't mind attempting to work around this without
major surgery. If we can't, then we can't, but lets not give up yet.
Or, more conservative, add another variable for how to control
roaming: attach or context activation (that can be applied also to
LTE).
That is along the lines of what I was thinking...
And decide globall, in the plug-in for the modem, or
subscription-based how to set this second variable (possibly all 3,
with overrides).
Feel free to propose something

Regards,
-Denis

Loading...