Skip to content

Commit e83da3b

Browse files
committed
uqmi: introduce devpath option
Introduce the devpath option to find the control channel device from a hardware path for a USB or a WWAN device. This option is useful when there are multiple modems connected to the system. The name of the control channel device of a modem can change depending on which modem initialises first or if it was recently plugged in. The devpath option allows specifying the hardware path of the modem where the control channel device will be found using that. For the USB device hardware path, it is allowed to specify the USB port number the modem is directly connected to. If the device and devpath options are both set, devpath takes precedence over device. The USB device hardware path of a control channel device can be found by: readlink -f /sys/class/usbmisc/cdc-wdmX/device The WWAN device hardware path of a control channel device can be found by: readlink -f /sys/class/wwan/wwanXqmiX/device An example uci configuration would be: config interface 'wwan_usb1' option proto 'qmi' option auth 'none' option devpath '/sys/devices/platform/1e1c0000.xhci/usb1/1-1' option apn 'internet' option pdptype 'ipv4v6' Or: config interface 'wwan_pcie1' option proto 'qmi' option auth 'none' option devpath '/sys/devices/platform/soc/11280000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0' option apn 'internet' option pdptype 'ipv4v6' Signed-off-by: Chester A. Unal <chester.a.unal@arinc9.com>
1 parent 764c503 commit e83da3b

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

  • package/network/utils/uqmi/files/lib/netifd/proto

package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ proto_qmi_init_config() {
2121
proto_config_add_string pdptype
2222
proto_config_add_int profile
2323
proto_config_add_int v6profile
24+
proto_config_add_string devpath
2425
proto_config_add_boolean dhcp
2526
proto_config_add_boolean dhcpv6
2627
proto_config_add_boolean sourcefilter
@@ -46,15 +47,39 @@ proto_qmi_setup() {
4647
local apn auth delay device modes password pdptype pincode username v6apn
4748
json_get_vars apn auth delay device modes password pdptype pincode username v6apn
4849

49-
local profile v6profile dhcp dhcpv6 autoconnect plmn timeout
50-
json_get_vars profile v6profile dhcp dhcpv6 autoconnect plmn timeout
50+
local profile v6profile devpath dhcp dhcpv6 autoconnect plmn timeout
51+
json_get_vars profile v6profile devpath dhcp dhcpv6 autoconnect plmn timeout
5152

5253
[ "$timeout" = "" ] && timeout="10"
5354

5455
[ "$metric" = "" ] && metric="0"
5556

5657
[ -n "$ctl_device" ] && device=$ctl_device
5758

59+
if [ -n "$devpath" ]; then
60+
local usbmisc_or_wwan_path
61+
# For usbmisc:
62+
# /sys/devices/platform/1e1c0000.xhci/usb1/1-2/1-2:1.4/usbmisc/cdc-wdm0
63+
# Numbers after ":" are the configuration and interface number
64+
# of the connected modem. There can be multiple interfaces but
65+
# there will only be a single interface that provides the
66+
# control channel device. Therefore, check also /*/usbmisc to
67+
# allow specifying the USB port number the modem is directly
68+
# connected to.
69+
# For wwan:
70+
# /sys/devices/platform/soc/11280000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0/wwan/wwan0/wwan0qmi0
71+
# /sys/devices/platform/soc/11280000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0/mhi0/wwan/wwan0/wwan0qmi0
72+
for usbmisc_or_wwan_path in \
73+
"$devpath"/usbmisc/cdc-wdm* \
74+
"$devpath"/*/usbmisc/cdc-wdm* \
75+
"$devpath"/*/wwan[0-9]*/wwan[0-9]*qmi* \
76+
"$devpath"/*/*/wwan[0-9]*/wwan[0-9]*qmi*; do
77+
[ ! -e "$usbmisc_or_wwan_path" ] && continue
78+
device="/dev/${usbmisc_or_wwan_path##*/}"
79+
break
80+
done
81+
fi
82+
5883
[ -n "$device" ] || {
5984
echo "No control device specified"
6085
proto_notify_error "$interface" NO_DEVICE
@@ -519,11 +544,22 @@ qmi_wds_stop() {
519544
proto_qmi_teardown() {
520545
local interface="$1"
521546

522-
local device cid_4 pdh_4 cid_6 pdh_6
523-
json_get_vars device
547+
local device devpath cid_4 pdh_4 cid_6 pdh_6
548+
json_get_vars device devpath
524549

525550
[ -n "$ctl_device" ] && device=$ctl_device
526551

552+
if [ -n "$devpath" ]; then
553+
local usbmisc_or_wwan_path
554+
for usbmisc_or_wwan_path in \
555+
"$devpath"/usbmisc/cdc-wdm* \
556+
"$devpath"/*/usbmisc/cdc-wdm* \
557+
"$devpath"/*/wwan[0-9]*/wwan[0-9]*qmi* \
558+
"$devpath"/*/*/wwan[0-9]*/wwan[0-9]*qmi*; do
559+
device="/dev/${usbmisc_or_wwan_path##*/}"
560+
done
561+
fi
562+
527563
echo "Stopping network $interface"
528564

529565
json_load "$(ubus call network.interface.$interface status)"

0 commit comments

Comments
 (0)