From b284b093773fbc7e305492a367b764dfe1dde4a5 Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Thu, 15 Feb 2024 12:40:58 +0100 Subject: [PATCH] Replace nrmodule2 by up2 in LTE 2x2 pipeline, use mbim scripts --- ci-scripts/ci_ueinfra.yaml | 12 +- ci-scripts/mbim_scripts/mbim-set-ip.sh | 221 ++++++++++++++++++ ci-scripts/mbim_scripts/start_quectel_mbim.sh | 10 + ci-scripts/mbim_scripts/stop_quectel_mbim.sh | 3 + .../container_lte_n3xx_tdd_2x2_tm1.xml | 29 +-- .../container_lte_n3xx_tdd_2x2_tm2.xml | 29 +-- 6 files changed, 255 insertions(+), 49 deletions(-) create mode 100644 ci-scripts/mbim_scripts/mbim-set-ip.sh create mode 100644 ci-scripts/mbim_scripts/start_quectel_mbim.sh create mode 100644 ci-scripts/mbim_scripts/stop_quectel_mbim.sh diff --git a/ci-scripts/ci_ueinfra.yaml b/ci-scripts/ci_ueinfra.yaml index f5aabf9167..deef3718ec 100644 --- a/ci-scripts/ci_ueinfra.yaml +++ b/ci-scripts/ci_ueinfra.yaml @@ -9,16 +9,14 @@ idefix: MTU: 1500 Trace: True LogStore: /media/usb-drive/ci_qlogs -nrmodule2_quectel: - Host: nrmodule2 - InitScript: sudo stdbuf -oL /home/nrmodule2/quectel-CM/quectel-CM -4 -s oai.ipv4 &> /tmp/quecel-cm.log & - TermScript: sudo -S killall --signal SIGKILL quectel-CM - AttachScript: sudo python3 ci_ctl_qtel.py /dev/ttyUSB2 wup - DetachScript: sudo python3 ci_ctl_qtel.py /dev/ttyUSB2 detach + +up2: + Host: up2 + AttachScript: sudo /opt/mbim/start_quectel_mbim.sh + DetachScript: sudo /opt/mbim/stop_quectel_mbim.sh NetworkScript: ip a show dev wwan0 IF: wwan0 MTU: 1500 - LogStore: /media/ci_qlogs adb_ue_1: Host: nano diff --git a/ci-scripts/mbim_scripts/mbim-set-ip.sh b/ci-scripts/mbim_scripts/mbim-set-ip.sh new file mode 100644 index 0000000000..572301540a --- /dev/null +++ b/ci-scripts/mbim_scripts/mbim-set-ip.sh @@ -0,0 +1,221 @@ +#!/bin/bash + +# Modified by Karim Boutiba (karim.boutiba@eurecom.fr) +# mbim-set-ip script version 1.1 +# Modified mbimcli IPv4 IPv6 parsing script based on parts of project https://github.com/grandcentrix/thinkpad-x260-modem-scripts +# Licensed under the Apache License, Version 2.0 +# Modified by Jörgen Storvist, Techship http://www.techship.com +# Further details in the Techship FAQ sections on using MBIM and setting correct modes in cellular modules: +# https://techship.com/faq/how-to-set-up-a-simple-data-connection-over-the-mbim-interface-using-libmbim-and-driver-cdc-mbim-in-linux/ +# +# Installation & Usage: +# +# Verify that the cellular module is exposing the MBIM interface over the USB interface. +# Use mbimcli to check status for the cellular connection and enter the PIN code if necessary. +# Configure mbim-network.conf and place in /etc/ (example file included in the archive, check link bellow for details). +# https://www.freedesktop.org/software/libmbim/man/latest/mbim-network.1.html +# Start the mbim data connection with command: +# mbim-network start +# Ensure execution of mbim-set-ip script with sufficient system priviledges +# ./mbim-set-ip +# +# Examples: +# mbimcli -d /dev/cdc-wdm0 -p --query-device-caps +# mbimcli -d /dev/cdc-wdm0 -p --enter-pin=1234 +# mbim-network /dev/cdc-wdm0 start +# ./mbim-set-ip /dev/cdc-wdm0 wwan0 +# +# You should now be able to ping over the data connection. +# IP v4 ping: (only if IPv4 address was acquired from cellular module) +# ping -4 -I wwan0 8.8.8.8 +# ping -4 -I wwan0 google.com + +# IP v6 ping: (only if IPv6 address was acquired from cellular module) +# ping -6 -I wwan0 2001:4860:4860::8888 +# ping -6 -I wwan0 google.com +# +# The script relies on the linux tools mbimcli, ip, systemd-resolve +# (Tested on libmbim 1.16.0 running on Ubuntu 18.10 cosmic (development) with kernel version 4.15.0) + +# Details on mbim-network and mbimcli +# https://www.freedesktop.org/software/libmbim/man/latest/mbim-network.1.html +# https://www.freedesktop.org/software/libmbim/man/latest/mbimcli.1.html + +ipv4_addresses=() +ipv4_gateway="" +ipv4_dns=() +ipv4_mtu="" +ipv6_addresses=() +ipv6_gateway="" +ipv6_dns=() +ipv6_mtu="" + +#CONTROL-IFACE +CONTROLDEV="$1" +#WWAN-IFACE +DEV="$2" +SESSION="$3" +echo $SESSION +echo "Requesting IPv4 and IPv6 information through mbimcli proxy:" +mbimcli -d $CONTROLDEV -p --query-ip-configuration +IPDATA=$(mbimcli -d $CONTROLDEV -p --query-ip-configuration=$SESSION) + +function parse_ip { + # IP [0]: '10.134.203.177/30' + local line_re="IP \[([0-9]+)\]: '(.+)'" + local input=$1 + if [[ $input =~ $line_re ]]; then + local ip_cnt=${BASH_REMATCH[1]} + local ip=${BASH_REMATCH[2]} + fi + echo "$ip" +} + +function parse_gateway { + # Gateway: '10.134.203.178' + local line_re="Gateway: '(.+)'" + local input=$1 + if [[ $input =~ $line_re ]]; then + local gw=${BASH_REMATCH[1]} + fi + echo "$gw" +} + +function parse_dns { + # DNS [0]: '10.134.203.177/30' + local line_re="DNS \[([0-9]+)\]: '(.+)'" + local input=$1 + if [[ $input =~ $line_re ]]; then + local dns_cnt=${BASH_REMATCH[1]} + local dns=${BASH_REMATCH[2]} + fi + echo "$dns" +} + +function parse_mtu { + # MTU: '1500' + local line_re="MTU: '([0-9]+)'" + local input=$1 + if [[ $input =~ $line_re ]]; then + local mtu=${BASH_REMATCH[1]} + fi + echo "$mtu" +} +while read -r line || [[ -n "$line" ]] ; do + [ -z "$line" ] && continue + case "$line" in + *"IPv4 configuration available: 'none'"*) + state="start" + continue + ;; + *"IPv4 configuration available"*) + state="ipv4" + continue + ;; + *"IPv6 configuration available: 'none'"*) + state="start" + continue + ;; + *"IPv6 configuration available"*) + state="ipv6" + continue + ;; + *) + ;; + esac + case "$state" in + "ipv4") + + case "$line" in + *"IP"*) + row=$(parse_ip "$line") + ipv4_addresses+=("$row") + continue + ;; + *"Gateway"*) + row=$(parse_gateway "$line") + ipv4_gateway="$row" + continue + ;; + *"DNS"*) + row=$(parse_dns "$line") + ipv4_dns+=("$row") + continue + ;; + *"MTU"*) + row=$(parse_mtu "$line") + ipv4_mtu="$row" + continue + ;; + *) + ;; + esac + ;; + + "ipv6") + case "$line" in + *"IP"*) + row=$(parse_ip "$line") + ipv6_addresses+=("$row") + continue + ;; + *"Gateway"*) + row=$(parse_gateway "$line") + ipv6_gateway="$row" + continue + ;; + *"DNS"*) + row=$(parse_dns "$line") + ipv6_dns+=("$row") + continue + ;; + *"MTU"*) + row=$(parse_mtu "$line") + ipv6_mtu="$row" + continue + ;; + *) + continue + ;; + esac + ;; + *) + continue + ;; + esac +done <<< "$IPDATA" + +execfile=$(mktemp) + +printf "ip link set $DEV down\n" >> $execfile +printf "ip addr flush dev $DEV \n" >> $execfile +printf "ip -6 addr flush dev $DEV \n" >> $execfile +printf "ip link set $DEV up\n" >> $execfile + +if [[ "${#ipv4_addresses[@]}" > 0 ]]; then + printf "ip addr add %s dev $DEV broadcast +\n" "${ipv4_addresses[@]}" >> $execfile + printf "ip route add 192.168.61.0/24 via $ipv4_gateway dev $DEV\n" >> $execfile + + if [ -n "$ipv4_mtu" ]; then + printf "ip link set mtu $ipv4_mtu dev $DEV \n" >> $execfile + fi + if [[ "${#ipv4_dns[@]}" > 0 ]]; then + printf "resolvectl -4 --interface=$DEV --set-dns=%s\n" "${ipv4_dns[@]}" >>$execfile + fi +fi + +if [[ "${#ipv6_addresses[@]}" > 0 ]]; then + printf "ip -6 addr add %s dev $DEV\n" "${ipv6_addresses[@]}" >> $execfile + printf "ip -6 route add default via $ipv6_gateway dev $DEV\n" >> $execfile + if [ -n "$ipv6_mtu" ]; then + printf "ip -6 link set mtu $ipv6_mtu dev $DEV\n" >> $execfile + fi + if [[ "${#ipv6_dns[@]}" > 0 ]]; then + printf "systemd-resolve -6 --interface=$DEV --set-dns=%s\n" "${ipv6_dns[@]}" >>$execfile + fi +fi +echo "Applying the following network interface configurations:" +cat $execfile +bash $execfile +rm $execfile +echo "Network interface configurations completed." diff --git a/ci-scripts/mbim_scripts/start_quectel_mbim.sh b/ci-scripts/mbim_scripts/start_quectel_mbim.sh new file mode 100644 index 0000000000..7f784e6adc --- /dev/null +++ b/ci-scripts/mbim_scripts/start_quectel_mbim.sh @@ -0,0 +1,10 @@ +set -x + +sudo mbimcli -p -d /dev/cdc-wdm0 --set-radio-state=off +sleep 1 +sudo mbimcli -p -d /dev/cdc-wdm0 --set-radio-state=on +sleep 2 +sudo mbimcli -p -d /dev/cdc-wdm0 --attach-packet-service + +sudo mbimcli -p -d /dev/cdc-wdm0 --connect=session-id=0,access-string=oai.ipv4,ip-type=ipv4 +sudo /opt/mbim/mbim-set-ip.sh /dev/cdc-wdm0 wwan0 0 diff --git a/ci-scripts/mbim_scripts/stop_quectel_mbim.sh b/ci-scripts/mbim_scripts/stop_quectel_mbim.sh new file mode 100644 index 0000000000..e7dbbaa43d --- /dev/null +++ b/ci-scripts/mbim_scripts/stop_quectel_mbim.sh @@ -0,0 +1,3 @@ +set -x + +sudo mbimcli -p -d /dev/cdc-wdm0 --set-radio-state=off diff --git a/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm1.xml b/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm1.xml index 49cd79783a..7bec0f8a83 100644 --- a/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm1.xml +++ b/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm1.xml @@ -30,7 +30,7 @@ 111111 100000 -010000 +010010 030101 010001 000001 @@ -39,7 +39,6 @@ 070000 070001 010010 -010002 030201 @@ -80,28 +79,16 @@ 5 - - Initialize_UE - Initialize Quectel - nrmodule2_quectel - - - - Terminate_UE - Terminate Quectel - nrmodule2_quectel - - Attach_UE Attach UE - nrmodule2_quectel + up2 Ping Ping: 20 pings - nrmodule2_quectel + up2 -c 20 %cn_ip% 1 60 @@ -110,8 +97,8 @@ Ping Ping: 100 pings, size 1024 - nrmodule2_quectel - -c 100 -s 1024 -i 0,2 %cn_ip% + up2 + -c 100 -s 1024 -i 0.2 %cn_ip% 1 60 @@ -121,7 +108,7 @@ iperf (DL/26Mbps/UDP)(60 sec)(single-ue profile) -u -b 26M -t 60 DL - nrmodule2_quectel + up2 5 95 single-ue @@ -132,7 +119,7 @@ iperf (UL/7Mbps/UDP)(60 sec)(single-ue profile) -u -b 7M -t 60 UL - nrmodule2_quectel + up2 5 95 single-ue @@ -141,7 +128,7 @@ Detach_UE Detach UE - nrmodule2_quectel + up2 diff --git a/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm2.xml b/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm2.xml index a9ed0b2bea..f57b77648c 100644 --- a/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm2.xml +++ b/ci-scripts/xml_files/container_lte_n3xx_tdd_2x2_tm2.xml @@ -30,7 +30,7 @@ 111111 100000 -010000 +010010 030101 010001 000001 @@ -39,7 +39,6 @@ 070000 070001 010010 -010002 030201 @@ -80,28 +79,16 @@ 5 - - Initialize_UE - Initialize Quectel - nrmodule2_quectel - - - - Terminate_UE - Terminate Quectel - nrmodule2_quectel - - Attach_UE Attach UE - nrmodule2_quectel + up2 Ping Ping: 20 pings - nrmodule2_quectel + up2 -c 20 %cn_ip% 1 60 @@ -110,8 +97,8 @@ Ping Ping: 100 pings, size 1024 - nrmodule2_quectel - -c 100 -s 1024 -i 0,2 %cn_ip% + up2 + -c 100 -s 1024 -i 0.2 %cn_ip% 1 60 @@ -121,7 +108,7 @@ iperf (DL/26Mbps/UDP)(60 sec)(single-ue profile) -u -b 1M -t 60 DL - nrmodule2_quectel + up2 5 95 single-ue @@ -132,7 +119,7 @@ iperf (UL/7Mbps/UDP)(60 sec)(single-ue profile) -u -b 7M -t 60 UL - nrmodule2_quectel + up2 5 95 single-ue @@ -141,7 +128,7 @@ Detach_UE Detach UE - nrmodule2_quectel + up2