summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-12-28 09:55:03 +0100
committerAleksander Morgado <aleksander@aleksander.es>2016-01-24 16:56:25 +0100
commitc2fa617177fdbb708710035e0ffe63e22fa772e2 (patch)
tree777ed8ae9fdb6c15d7dd8712abdc7e3369e702a7
parent3be94e17b175cefb5dc984e8aff13afffe6aa068 (diff)
qmi-network: if kernel allows updating LLP, prefer device-reported LLP
In new kernels, updating expected LLP is a valid operation. If so, we prefer changing the expected LLP in the kernel instead of in the device, because new chipsets like the MC7455 only do raw-ip.
-rwxr-xr-xutils/qmi-network.in127
1 files changed, 90 insertions, 37 deletions
diff --git a/utils/qmi-network.in b/utils/qmi-network.in
index d6a2871..b7b22ca 100755
--- a/utils/qmi-network.in
+++ b/utils/qmi-network.in
@@ -199,28 +199,16 @@ clear_state ()
rm -f $STATE_FILE
}
-# qmicli -d /dev/cdc-wdm0 --wds-start-network --client-no-release-cid
-# [/dev/cdc-wdm0] Network started
-# Packet data handle: 3634026241
-# [/dev/cdc-wdm0] Client ID not released:
-# Service: 'wds'
-# CID: '80'
-start_network ()
+setup_data_format ()
{
- if [ "x$CID" != "x" ]; then
- USE_PREVIOUS_CID="--client-cid=$CID"
- fi
+ RUN_WDA=0
- if [ "x$PDH" != "x" ]; then
- echo "error: cannot re-start network, PDH already exists" 1>&2
- exit 3
- fi
+ # Read link layer protocol setup in the device
- # Read link layer protocol
- DATA_FORMAT_CMD="qmicli -d $DEVICE --wda-get-data-format $PROXY_OPT"
- echo "Checking data format with '$DATA_FORMAT_CMD'..."
+ DEVICE_DATA_FORMAT_CMD="qmicli -d $DEVICE --wda-get-data-format $PROXY_OPT"
+ echo "Checking data format with '$DEVICE_DATA_FORMAT_CMD'..."
if [ "x$QMIDEBUG" != "x" ]; then
- DATA_FORMAT_OUT="\
+ DEVICE_DATA_FORMAT_OUT="\
[/dev/cdc-wdm1] Successfully got data format
QoS flow header: no
Link layer protocol: '802-3'
@@ -230,19 +218,56 @@ Downlink data aggregation protocol: 'disabled'
Uplink data aggregation max size: '0'
Downlink data aggregation max size: '0'"
else
- DATA_FORMAT_OUT=`$DATA_FORMAT_CMD`
+ DEVICE_DATA_FORMAT_OUT=`$DEVICE_DATA_FORMAT_CMD`
fi
+ DEVICE_LLP=`echo "$DEVICE_DATA_FORMAT_OUT" | sed -n "s/.*Link layer protocol:.*'\(.*\)'.*/\1/p"`
- LLP=`echo "$DATA_FORMAT_OUT" | sed -n "s/.*Link layer protocol:.*'\(.*\)'.*/\1/p"`
- if [ "x$LLP" = "x" ]; then
- echo "Link layer protocol not retrieved" 1>&2
+ if [ "x$DEVICE_LLP" = "x" ]; then
+ echo "Device link layer protocol not retrieved: WDA unsupported" 1>&2
+ return
+ fi
+
+ if [ "$DEVICE_LLP" != "802-3" -a "$DEVICE_LLP" != "raw-ip" ]; then
+ echo "Device link layer protocol not retrieved: unexpected value reported: '$DEVICE_LLP'" 1>&2
+ return
+ fi
+ echo "Device link layer protocol retrieved: $DEVICE_LLP"
+
+ # Read link layer protocol setup in the kernel
+
+ EXPECTED_DATA_FORMAT_CMD="qmicli -d $DEVICE --get-expected-data-format"
+ echo "Getting expected data format with '$EXPECTED_DATA_FORMAT_CMD'..."
+ if [ "x$QMIDEBUG" != "x" ]; then
+ EXPECTED_LLP="raw-ip"
else
- echo "Link layer protocol retrieved: $LLP" 1>&2
- if [ "x$LLP" != "x802-3" ]; then
- DATA_FORMAT_SET_CMD="qmicli -d $DEVICE --wda-set-data-format=802-3 $PROXY_OPT"
- echo "Updating data format with '$DATA_FORMAT_SET_CMD'..."
- if [ "x$QMIDEBUG" != "x" ]; then
- DATA_FORMAT_SET_OUT="\
+ EXPECTED_DATA_FORMAT_OUT=`$EXPECTED_DATA_FORMAT_CMD`
+ if [ $? -eq 0 ]; then
+ EXPECTED_LLP=$EXPECTED_DATA_FORMAT_OUT
+ echo "Expected link layer protocol retrieved: $EXPECTED_LLP"
+ else
+ echo "Expected link layer protocol not retrieved: kernel unsupported" 1>&2
+ EXPECTED_LLP="802-3"
+ # The kernel doesn't support expected data format, so we change the
+ # device data format instead
+ RUN_WDA=1
+ fi
+ fi
+
+ if [ "$EXPECTED_LLP" != "802-3" -a "$EXPECTED_LLP" != "raw-ip" ]; then
+ echo "Expected link layer protocol not retrieved: unexpected value reported: '$EXPECTED_LLP'" 1>&2
+ return
+ fi
+
+ if [ "$DEVICE_LLP" == "$EXPECTED_LLP" ]; then
+ echo "Device and kernel link layer protocol match: $DEVICE_LLP"
+ return
+ fi
+
+ if [ $RUN_WDA -eq 1 ]; then
+ DEVICE_DATA_FORMAT_SET_CMD="qmicli -d $DEVICE --wda-set-data-format=$EXPECTED_LLP $PROXY_OPT"
+ echo "Updating device link layer protocol with '$DEVICE_DATA_FORMAT_SET_CMD'..."
+ if [ "x$QMIDEBUG" != "x" ]; then
+ DEVICE_DATA_FORMAT_SET_OUT="\
[/dev/cdc-wdm1] Successfully set data format
QoS flow header: no
Link layer protocol: '802-3'
@@ -251,18 +276,46 @@ Downlink data aggregation max size: '0'"
NDP signature: '0'
Downlink data aggregation max datagrams: '0'
Downlink data aggregation max size: '0'"
- else
- DATA_FORMAT_SET_OUT=`$DATA_FORMAT_SET_CMD`
- fi
+ else
+ DEVICE_DATA_FORMAT_SET_OUT=`$DEVICE_DATA_FORMAT_SET_CMD`
+ fi
- LLP=`echo "$DATA_FORMAT_SET_OUT" | sed -n "s/.*Link layer protocol:.*'\(.*\)'.*/\1/p"`
- if [ "x$LLP" = "x" ]; then
- echo "Link layer protocol not retrieved after update" 1>&2
- else
- echo "New link layer protocol retrieved: $LLP" 1>&2
- fi
+ LLP=`echo "$DEVICE_DATA_FORMAT_SET_OUT" | sed -n "s/.*Link layer protocol:.*'\(.*\)'.*/\1/p"`
+ if [ "x$LLP" = "x" ]; then
+ echo "Error updating Device link layer protocol" 1>&2
+ else
+ echo "New device link layer protocol retrieved: $LLP"
+ fi
+ else
+ EXPECTED_DATA_FORMAT_SET_CMD="qmicli -d $DEVICE --set-expected-data-format=$DEVICE_LLP"
+ echo "Updating kernel link layer protocol with '$EXPECTED_DATA_FORMAT_SET_CMD'..."
+ EXPECTED_DATA_FORMAT_SET_OUT=`$EXPECTED_DATA_FORMAT_SET_CMD`
+ if [ $? -eq 0 ]; then
+ echo "Kernel link layer protocol updated"
+ else
+ echo "Error updating kernel link layer protocol " 1>&2
fi
fi
+}
+
+# qmicli -d /dev/cdc-wdm0 --wds-start-network --client-no-release-cid
+# [/dev/cdc-wdm0] Network started
+# Packet data handle: 3634026241
+# [/dev/cdc-wdm0] Client ID not released:
+# Service: 'wds'
+# CID: '80'
+start_network ()
+{
+ if [ "x$CID" != "x" ]; then
+ USE_PREVIOUS_CID="--client-cid=$CID"
+ fi
+
+ if [ "x$PDH" != "x" ]; then
+ echo "error: cannot re-start network, PDH already exists" 1>&2
+ exit 3
+ fi
+
+ setup_data_format
START_NETWORK_CMD="qmicli -d $DEVICE --wds-start-network=$APN $USE_PREVIOUS_CID --client-no-release-cid $PROXY_OPT"
echo "Starting network with '$START_NETWORK_CMD'..."