summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChester A. Unal2026-02-09 10:55:02 +0000
committerHauke Mehrtens2026-03-30 11:02:58 +0000
commit8a18e84a887379db8954449a9fabe6df54084dea (patch)
treeb8275779d70edf2044688cc60bd6606defc5d5f9
parentfcd535c0f281a289e558142081d89a85ca28aff4 (diff)
downloadopenwrt-8a18e84a887379db8954449a9fabe6df54084dea.tar.gz
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> (cherry picked from commit e83da3badaf994f0f1c072b7ed11b6317b70aeac) Link: https://github.com/openwrt/openwrt/pull/22254 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rwxr-xr-xpackage/network/utils/uqmi/files/lib/netifd/proto/qmi.sh44
1 files changed, 40 insertions, 4 deletions
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 8297e6b3f0..8f45e25ee4 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -21,6 +21,7 @@ proto_qmi_init_config() {
proto_config_add_string pdptype
proto_config_add_int profile
proto_config_add_int v6profile
+ proto_config_add_string devpath
proto_config_add_boolean dhcp
proto_config_add_boolean dhcpv6
proto_config_add_boolean sourcefilter
@@ -46,8 +47,8 @@ proto_qmi_setup() {
local apn auth delay device modes password pdptype pincode username v6apn
json_get_vars apn auth delay device modes password pdptype pincode username v6apn
- local profile v6profile dhcp dhcpv6 autoconnect plmn timeout
- json_get_vars profile v6profile dhcp dhcpv6 autoconnect plmn timeout
+ local profile v6profile devpath dhcp dhcpv6 autoconnect plmn timeout
+ json_get_vars profile v6profile devpath dhcp dhcpv6 autoconnect plmn timeout
[ "$timeout" = "" ] && timeout="10"
@@ -55,6 +56,30 @@ proto_qmi_setup() {
[ -n "$ctl_device" ] && device=$ctl_device
+ if [ -n "$devpath" ]; then
+ local usbmisc_or_wwan_path
+ # For usbmisc:
+ # /sys/devices/platform/1e1c0000.xhci/usb1/1-2/1-2:1.4/usbmisc/cdc-wdm0
+ # Numbers after ":" are the configuration and interface number
+ # of the connected modem. There can be multiple interfaces but
+ # there will only be a single interface that provides the
+ # control channel device. Therefore, check also /*/usbmisc to
+ # allow specifying the USB port number the modem is directly
+ # connected to.
+ # For wwan:
+ # /sys/devices/platform/soc/11280000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0/wwan/wwan0/wwan0qmi0
+ # /sys/devices/platform/soc/11280000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0/mhi0/wwan/wwan0/wwan0qmi0
+ for usbmisc_or_wwan_path in \
+ "$devpath"/usbmisc/cdc-wdm* \
+ "$devpath"/*/usbmisc/cdc-wdm* \
+ "$devpath"/*/wwan[0-9]*/wwan[0-9]*qmi* \
+ "$devpath"/*/*/wwan[0-9]*/wwan[0-9]*qmi*; do
+ [ ! -e "$usbmisc_or_wwan_path" ] && continue
+ device="/dev/${usbmisc_or_wwan_path##*/}"
+ break
+ done
+ fi
+
[ -n "$device" ] || {
echo "No control device specified"
proto_notify_error "$interface" NO_DEVICE
@@ -519,11 +544,22 @@ qmi_wds_stop() {
proto_qmi_teardown() {
local interface="$1"
- local device cid_4 pdh_4 cid_6 pdh_6
- json_get_vars device
+ local device devpath cid_4 pdh_4 cid_6 pdh_6
+ json_get_vars device devpath
[ -n "$ctl_device" ] && device=$ctl_device
+ if [ -n "$devpath" ]; then
+ local usbmisc_or_wwan_path
+ for usbmisc_or_wwan_path in \
+ "$devpath"/usbmisc/cdc-wdm* \
+ "$devpath"/*/usbmisc/cdc-wdm* \
+ "$devpath"/*/wwan[0-9]*/wwan[0-9]*qmi* \
+ "$devpath"/*/*/wwan[0-9]*/wwan[0-9]*qmi*; do
+ device="/dev/${usbmisc_or_wwan_path##*/}"
+ done
+ fi
+
echo "Stopping network $interface"
json_load "$(ubus call network.interface.$interface status)"