diff mbox series

[LEDE-DEV,v2] uqmi: fix raw-ip mode for newer lte modems

Message ID 1511803890-14127-1-git-send-email-koen.vandeputte@ncentric.com
State Accepted
Headers show
Series [LEDE-DEV,v2] uqmi: fix raw-ip mode for newer lte modems | expand

Commit Message

Koen Vandeputte Nov. 27, 2017, 5:31 p.m. UTC
Some newer LTE modems, like the MC7455 or EC25-E do not support
"802.3" mode, and will stay in "raw-ip" regardless of the mode being
set.

In this case, the driver must be informed that it should handle all
packets in raw mode. [1]

This commit fixes connectivity issues for these devices.

Before:

[ Node 5 ] udhcpc -i wwan0
udhcpc: started, v1.27.2
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover

After:

[ Node 5 ] udhcpc -i wwan0
udhcpc: started, v1.27.2
udhcpc: sending discover
udhcpc: sending select for 100.66.245.226
udhcpc: lease of 100.66.245.226 obtained, lease time 7200
udhcpc: ifconfig wwan0 100.66.245.226 netmask 255.255.255.252 broadcast
+
udhcpc: setting default routers: 100.66.245.225

[1] https://lists.freedesktop.org/archives/libqmi-
devel/2017-January/002064.html

Tested on cns3xxx using a Sierra Wireless MC7455 LTE-A

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
---

V2: Add existence test for required driver attribute.  Bail out in case it's needed but doesn't exist


 package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Nicholas Smith Nov. 27, 2017, 10:38 p.m. UTC | #1
Hi!

Will this also apply to the Sierra MC7430, as it is also raw-ip only?  If I am not mistaken it is the same as the MC7455, just for the Asia/Pacific region.  I would be able to verify this patch on the device.  To verify that it works, do I just look for /sys/class/net/$ifname/qmi/raw_ip ?

Nicholas 
smith.nicholas910@gmail.com

> On 28 Nov 2017, at 3:31 am, Koen Vandeputte <koen.vandeputte@ncentric.com> wrote:
> 
> Some newer LTE modems, like the MC7455 or EC25-E do not support
> "802.3" mode, and will stay in "raw-ip" regardless of the mode being
> set.
> 
> In this case, the driver must be informed that it should handle all
> packets in raw mode. [1]
> 
> This commit fixes connectivity issues for these devices.
> 
> Before:
> 
> [ Node 5 ] udhcpc -i wwan0
> udhcpc: started, v1.27.2
> udhcpc: sending discover
> udhcpc: sending discover
> udhcpc: sending discover
> 
> After:
> 
> [ Node 5 ] udhcpc -i wwan0
> udhcpc: started, v1.27.2
> udhcpc: sending discover
> udhcpc: sending select for 100.66.245.226
> udhcpc: lease of 100.66.245.226 obtained, lease time 7200
> udhcpc: ifconfig wwan0 100.66.245.226 netmask 255.255.255.252 broadcast
> +
> udhcpc: setting default routers: 100.66.245.225
> 
> [1] https://lists.freedesktop.org/archives/libqmi-
> devel/2017-January/002064.html
> 
> Tested on cns3xxx using a Sierra Wireless MC7455 LTE-A
> 
> Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
> ---
> 
> V2: Add existence test for required driver attribute.  Bail out in case it's needed but doesn't exist
> 
> 
> package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
> index 9c953ea..9a534d4 100755
> --- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
> +++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
> @@ -27,7 +27,7 @@ proto_qmi_init_config() {
> 
> proto_qmi_setup() {
> 	local interface="$1"
> -
> +	local dataformat
> 	local device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn $PROTO_DEFAULT_OPTIONS
> 	local cid_4 pdh_4 cid_6 pdh_6
> 	local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
> @@ -99,6 +99,19 @@ proto_qmi_setup() {
> 
> 	uqmi -s -d "$device" --set-data-format 802.3
> 	uqmi -s -d "$device" --wda-set-data-format 802.3
> +	dataformat="$(uqmi -s -d "$device" --wda-get-data-format)"
> +
> +	if [ "$dataformat" = '"raw-ip"' ]; then
> +
> +		[ -f /sys/class/net/$ifname/qmi/raw_ip ] || {
> +			echo "Device only supports raw-ip mode but is missing this required driver attribute: /sys/class/net/$ifname/qmi/raw_ip"
> +			return 1
> +		}
> +
> +		echo "Device does not support 802.3 mode. Informing driver of raw-ip only for $ifname .."
> +		echo "Y" > /sys/class/net/$ifname/qmi/raw_ip
> +	fi
> +
> 	uqmi -s -d "$device" --sync
> 
> 	echo "Waiting for network registration"
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
Koen Vandeputte Nov. 28, 2017, 8:27 a.m. UTC | #2
On 2017-11-27 23:38, Nicholas Smith wrote:
> Hi!
>
> Will this also apply to the Sierra MC7430, as it is also raw-ip only?  If I am not mistaken it is the same as the MC7455, just for the Asia/Pacific region.  I would be able to verify this patch on the device.  To verify that it works, do I just look for /sys/class/net/$ifname/qmi/raw_ip ?
>
> Nicholas
> smith.nicholas910@gmail.com
>
<snip>

Judging by the datasheet compared to the MC7455 and some other resources 
online:  most likely yes.
Keep in mind that this will not work on the 17.01 branch as kernel 4.5 
or better is required which contains the needed driver parts and fixes.

If you would like to evaluate, please use master branch.

Testing the patch in full checking connectivity is always better than 
just checking if that particular file is present.
You should see a print referring to raw-ip popping up using logread. 
(see patch contents)


Regards,

Koen
Jo-Philipp Wich Nov. 28, 2017, 5:28 p.m. UTC | #3
Merged into my staging tree with
http://git.lede-project.org/?p=lede/jow/staging.git;a=commitdiff;h=36b31d2c49.

Thank you!
Nicholas Smith Nov. 30, 2017, 3:49 a.m. UTC | #4
Hi Koen,

I would like to report that it is attempting, but it is unable to change /sys/class/wwan0/qmi/raw_ip to a “Y” on it’s own.  I have to bring the interface down myself, set raw_ip to Y, then bring it back up.  Manual, but it works every time.

[   40.455550] qmi_wwan 1-2:1.8 wwan0: Cannot change a running device

Here’s what I do to work around:

In LuCI go to wwan0 and stop the interface.
echo “Y” > /sys/class/wwan0/qmi/raw_ip
In LuCI go to wwan0 and connect the interface.



> On 28 Nov 2017, at 6:27 pm, Koen Vandeputte <koen.vandeputte@ncentric.com> wrote:
> 
> 
> 
> On 2017-11-27 23:38, Nicholas Smith wrote:
>> Hi!
>> 
>> Will this also apply to the Sierra MC7430, as it is also raw-ip only?  If I am not mistaken it is the same as the MC7455, just for the Asia/Pacific region.  I would be able to verify this patch on the device.  To verify that it works, do I just look for /sys/class/net/$ifname/qmi/raw_ip ?
>> 
>> Nicholas
>> smith.nicholas910@gmail.com
>> 
> <snip>
> 
> Judging by the datasheet compared to the MC7455 and some other resources online:  most likely yes.
> Keep in mind that this will not work on the 17.01 branch as kernel 4.5 or better is required which contains the needed driver parts and fixes.
> 
> If you would like to evaluate, please use master branch.
> 
> Testing the patch in full checking connectivity is always better than just checking if that particular file is present.
> You should see a print referring to raw-ip popping up using logread. (see patch contents)
> 
> 
> Regards,
> 
> Koen
Nicholas Smith Nov. 30, 2017, 3:53 a.m. UTC | #5
Here is the VID:PID of the MC7430, if it helps.
Bus 001 Device 002: ID 1199:9071 Sierra Wireless, Inc. 


> On 30 Nov 2017, at 1:49 pm, Nicholas Smith <smith.nicholas910@gmail.com> wrote:
> 
> Hi Koen,
> 
> I would like to report that it is attempting, but it is unable to change /sys/class/wwan0/qmi/raw_ip to a “Y” on it’s own.  I have to bring the interface down myself, set raw_ip to Y, then bring it back up.  Manual, but it works every time.
> 
> [   40.455550] qmi_wwan 1-2:1.8 wwan0: Cannot change a running device
> 
> Here’s what I do to work around:
> 
> In LuCI go to wwan0 and stop the interface.
> echo “Y” > /sys/class/wwan0/qmi/raw_ip
> In LuCI go to wwan0 and connect the interface.
> 
> 
> 
>> On 28 Nov 2017, at 6:27 pm, Koen Vandeputte <koen.vandeputte@ncentric.com> wrote:
>> 
>> 
>> 
>> On 2017-11-27 23:38, Nicholas Smith wrote:
>>> Hi!
>>> 
>>> Will this also apply to the Sierra MC7430, as it is also raw-ip only?  If I am not mistaken it is the same as the MC7455, just for the Asia/Pacific region.  I would be able to verify this patch on the device.  To verify that it works, do I just look for /sys/class/net/$ifname/qmi/raw_ip ?
>>> 
>>> Nicholas
>>> smith.nicholas910@gmail.com
>>> 
>> <snip>
>> 
>> Judging by the datasheet compared to the MC7455 and some other resources online:  most likely yes.
>> Keep in mind that this will not work on the 17.01 branch as kernel 4.5 or better is required which contains the needed driver parts and fixes.
>> 
>> If you would like to evaluate, please use master branch.
>> 
>> Testing the patch in full checking connectivity is always better than just checking if that particular file is present.
>> You should see a print referring to raw-ip popping up using logread. (see patch contents)
>> 
>> 
>> Regards,
>> 
>> Koen
>
Koen Vandeputte Nov. 30, 2017, 8:41 a.m. UTC | #6
On 2017-11-30 04:53, Nicholas Smith wrote:
> Here is the VID:PID of the MC7430, if it helps.
> Bus 001 Device 002: ID 1199:9071 Sierra Wireless, Inc.
>
>
>> On 30 Nov 2017, at 1:49 pm, Nicholas Smith <smith.nicholas910@gmail.com> wrote:
>>
>> Hi Koen,
>>
>> I would like to report that it is attempting, but it is unable to change /sys/class/wwan0/qmi/raw_ip to a “Y” on it’s own.  I have to bring the interface down myself, set raw_ip to Y, then bring it back up.  Manual, but it works every time.
>>
>> [   40.455550] qmi_wwan 1-2:1.8 wwan0: Cannot change a running device
>>
>> Here’s what I do to work around:
>>
>> In LuCI go to wwan0 and stop the interface.
>> echo “Y” > /sys/class/wwan0/qmi/raw_ip
>> In LuCI go to wwan0 and connect the interface.
>>
>>
<snip>

Hi Nicholas,

Thanks for your time in testing this.

Just to be sure:
Can you confirm you've used the latest master and applied my patch 
before seeing this error?

I'm not able to simulate your error here currently, and the script 
manages to adapt this flag on each run.


Besides the error you notice, is your modem fully working now providing 
a working uplink?


Thanks again,

Koen
Koen Vandeputte Nov. 30, 2017, 8:51 a.m. UTC | #7
On 2017-11-30 09:45, Nicholas Smith wrote:
> No, thank you, Koen, for researching and developing the patch! 
> Actually I am running the latest snapshot build. I suppose there in 
> could lie the issue.
> On Thu, 30 Nov 2017 at 6:41 pm, Koen Vandeputte 
> <koen.vandeputte@ncentric.com <mailto:koen.vandeputte@ncentric.com>> 
> wrote:
>
<snip>

Hi Nicholas,

As a shortcut, replace following script on your device with the one 
attached:

/lib/netifd/proto/qmi.sh


Make sure you set it executable:
chmod +rwx /lib/netifd/proto/qmi.sh


Then reboot & test


Koen
diff mbox series

Patch

diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index 9c953ea..9a534d4 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -27,7 +27,7 @@  proto_qmi_init_config() {
 
 proto_qmi_setup() {
 	local interface="$1"
-
+	local dataformat
 	local device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn $PROTO_DEFAULT_OPTIONS
 	local cid_4 pdh_4 cid_6 pdh_6
 	local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
@@ -99,6 +99,19 @@  proto_qmi_setup() {
 
 	uqmi -s -d "$device" --set-data-format 802.3
 	uqmi -s -d "$device" --wda-set-data-format 802.3
+	dataformat="$(uqmi -s -d "$device" --wda-get-data-format)"
+
+	if [ "$dataformat" = '"raw-ip"' ]; then
+
+		[ -f /sys/class/net/$ifname/qmi/raw_ip ] || {
+			echo "Device only supports raw-ip mode but is missing this required driver attribute: /sys/class/net/$ifname/qmi/raw_ip"
+			return 1
+		}
+
+		echo "Device does not support 802.3 mode. Informing driver of raw-ip only for $ifname .."
+		echo "Y" > /sys/class/net/$ifname/qmi/raw_ip
+	fi
+
 	uqmi -s -d "$device" --sync
 
 	echo "Waiting for network registration"