Skip to content

Commit 764c503

Browse files
committed
umbim: 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/wwanXmbimX/device An example uci configuration would be: config interface 'wwan_usb1' option proto 'mbim' 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 'mbim' 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 c4e2850 commit 764c503

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

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

package/network/utils/umbim/files/lib/netifd/proto/mbim.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ proto_mbim_init_config() {
2020
proto_config_add_string username
2121
proto_config_add_string password
2222
[ -e /proc/sys/net/ipv6 ] && proto_config_add_string ipv6
23+
proto_config_add_string devpath
2324
proto_config_add_string dhcp
2425
proto_config_add_string dhcpv6
2526
proto_config_add_boolean sourcefilter
@@ -46,8 +47,8 @@ _proto_mbim_setup() {
4647
local tid=2
4748
local ret
4849

49-
local allow_partner allow_roaming apn auth delay device password pincode username
50-
json_get_vars allow_partner allow_roaming apn auth delay device password pincode username
50+
local allow_partner allow_roaming apn auth delay device devpath password pincode username
51+
json_get_vars allow_partner allow_roaming apn auth delay device devpath password pincode username
5152

5253
local dhcp dhcpv6 pdptype
5354
json_get_vars dhcp dhcpv6 pdptype
@@ -59,6 +60,30 @@ _proto_mbim_setup() {
5960

6061
[ -n "$ctl_device" ] && device=$ctl_device
6162

63+
if [ -n "$devpath" ]; then
64+
local usbmisc_or_wwan_path
65+
# For usbmisc:
66+
# /sys/devices/platform/1e1c0000.xhci/usb1/1-2/1-2:1.4/usbmisc/cdc-wdm0
67+
# Numbers after ":" are the configuration and interface number
68+
# of the connected modem. There can be multiple interfaces but
69+
# there will only be a single interface that provides the
70+
# control channel device. Therefore, check also /*/usbmisc to
71+
# allow specifying the USB port number the modem is directly
72+
# connected to.
73+
# For wwan:
74+
# /sys/devices/platform/soc/11280000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0/wwan/wwan0/wwan0mbim0
75+
# /sys/devices/platform/soc/11280000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0/mhi0/wwan/wwan0/wwan0mbim0
76+
for usbmisc_or_wwan_path in \
77+
"$devpath"/usbmisc/cdc-wdm* \
78+
"$devpath"/*/usbmisc/cdc-wdm* \
79+
"$devpath"/*/wwan[0-9]*/wwan[0-9]*mbim* \
80+
"$devpath"/*/*/wwan[0-9]*/wwan[0-9]*mbim*; do
81+
[ ! -e "$usbmisc_or_wwan_path" ] && continue
82+
device="/dev/${usbmisc_or_wwan_path##*/}"
83+
break
84+
done
85+
fi
86+
6287
[ -n "$device" ] || {
6388
echo "mbim[$$]" "No control device specified"
6489
proto_notify_error "$interface" NO_DEVICE
@@ -321,12 +346,23 @@ proto_mbim_setup() {
321346
proto_mbim_teardown() {
322347
local interface="$1"
323348

324-
local device
325-
json_get_vars device
349+
local device devpath
350+
json_get_vars device devpath
326351
local tid=$(uci_get_state network $interface tid)
327352

328353
[ -n "$ctl_device" ] && device=$ctl_device
329354

355+
if [ -n "$devpath" ]; then
356+
local usbmisc_or_wwan_path
357+
for usbmisc_or_wwan_path in \
358+
"$devpath"/usbmisc/cdc-wdm* \
359+
"$devpath"/*/usbmisc/cdc-wdm* \
360+
"$devpath"/*/wwan[0-9]*/wwan[0-9]*mbim* \
361+
"$devpath"/*/*/wwan[0-9]*/wwan[0-9]*mbim*; do
362+
device="/dev/${usbmisc_or_wwan_path##*/}"
363+
done
364+
fi
365+
330366
echo "mbim[$$]" "Stopping network"
331367
[ -n "$tid" ] && {
332368
umbim $DBG -t $tid -d "$device" disconnect

0 commit comments

Comments
 (0)