root@OpenWrt:~# insmod pcie_mhi.ko mhi_mbim_enabled=1
root@OpenWrt:~# dmesg | grep mhi
[   65.587160] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.6
[   65.597089] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306
[   65.602250] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x20300000-0x20300fff 64bit]
[   65.611690] mhi_q 0000:01:00.0: enabling device (0140 -> 0142)
[   65.619307] [I][mhi_init_pci_dev] msi_required = 5, msi_allocated = 5, msi_irq = 63
[   65.619327] [I][mhi_power_up] dev_state:RESET
[   65.619331] [I][mhi_async_power_up] Requested to power on
[   65.619449] [I][mhi_alloc_coherent] size = 114688, dma_handle = 6fca0000
[   65.619462] [I][mhi_init_dev_ctxt] mhi_ctxt->ctrl_seg = c221e000
[   65.619731] [I][mhi_async_power_up] dev_state:RESET ee:AMSS
[   65.619747] [I][mhi_pm_st_worker] Transition to state:READY
[   65.619760] [I][mhi_pm_st_worker] INVALID_EE -> AMSS
[   65.619764] [I][mhi_ready_state_transition] Waiting to enter READY state
[   65.619885] [I][mhi_async_power_up] Power on setup success
[   65.619897] [I][mhi_pci_probe] Return successful
[   65.665114] [I][mhi_ready_state_transition] Device in READY State
[   65.665125] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, pm_state:POR
[   65.665131] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, INVALID_EE
[   65.665133] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:POR
[   65.665137] [I][mhi_init_mmio] Initializing MMIO
[   65.665142] [I][mhi_init_mmio] CHDBOFF:0x300
[   65.665151] [I][mhi_init_mmio] ERDBOFF:0x700
[   65.665156] [I][mhi_init_mmio] Programming all MMIO values.
[   65.786283] [I][mhi_dump_tre] carl_ev evt_state_change mhistate=2
[   65.786289] [I][mhi_process_ctrl_ev_ring] MHI state change event to state:M0
[   65.786295] [I][mhi_pm_m0_transition] Entered With State:READY PM_STATE:POR
[   65.786300] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:M0
[   65.789734] [I][mhi_dump_tre] carl_ev evt_ee_state execenv=2
[   65.789739] [I][mhi_process_ctrl_ev_ring] MHI EE received event:AMSS
[   65.789756] [I][mhi_pm_st_worker] Transition to state:MISSION MODE
[   65.789767] [I][mhi_pm_st_worker] INVALID_EE -> AMSS
[   65.789771] [I][mhi_pm_mission_mode_transition] Processing Mission Mode Transition
[   65.789787] [I][mhi_init_timesync] No timesync capability found
[   65.789791] [I][mhi_pm_mission_mode_transition] Adding new devices
[   65.790570] [I][mhi_dtr_probe] Enter for DTR control channel
[   65.790577] [I][__mhi_prepare_channel] Entered: preparing channel:18
[   65.797036] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1
[   65.797051] [I][__mhi_prepare_channel] Chan:18 successfully moved to start state
[   65.797055] [I][__mhi_prepare_channel] Entered: preparing channel:19
[   65.802457] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1
[   65.802469] [I][__mhi_prepare_channel] Chan:19 successfully moved to start state
[   65.802485] [I][mhi_dtr_probe] Exit with ret:0
[   65.802748] [I][mhi_netdev_enable_iface] Prepare the channels for transfer
[   65.802772] [I][__mhi_prepare_channel] Entered: preparing channel:100
[   65.825279] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1
[   65.825293] [I][__mhi_prepare_channel] Chan:100 successfully moved to start state
[   65.825297] [I][__mhi_prepare_channel] Entered: preparing channel:101
[   65.835565] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1
[   65.835578] [I][__mhi_prepare_channel] Chan:101 successfully moved to start state
[   65.839141] [I][mhi_netdev_enable_iface] Exited.
[   65.839875] rmnet_vnd_register_device(rmnet_mhi0.1)=0
[   65.843278] net rmnet_mhi0 rmnet_mhi0.1: NSS context created
[   65.861808] [I][mhi_pm_mission_mode_transition] Exit with ret:0
[   68.625595] [I][__mhi_prepare_channel] Entered: preparing channel:12
[   68.634610] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1
[   68.634622] [I][__mhi_prepare_channel] Chan:12 successfully moved to start state
[   68.634625] [I][__mhi_prepare_channel] Entered: preparing channel:13
[   68.644978] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1
[   68.644987] [I][__mhi_prepare_channel] Chan:13 successfully moved to start state
[   69.170666] net rmnet_mhi0: link_state 0x0 -> 0x1
[   69.177035] [I][mhi_netdev_open] Opened net dev interface
[   71.655431] [I][mhi_netdev_open] Opened net dev interface

root@OpenWrt:~# ./quectel-CM &
[04-02_04:14:12:134] Quectel_QConnectManager_Linux_V1.6.0.5
[04-02_04:14:12:134] Find /sys/bus/usb/devices/4-1 idVendor=0x2c7c idProduct=0x800, bus=0x004, dev=0x002
[04-02_04:14:12:135] network interface '' or qmidev '' is not exist
[04-02_04:14:12:135] netcard driver = pcie_mhi, driver version = V1.3.0.6
[04-02_04:14:12:135] Modem works in MBIM mode
[04-02_04:14:12:135] apn (null), user (null), passwd (null), auth 0
[04-02_04:14:12:135] IP Proto MBIMContextIPTypeIPv4
[04-02_04:14:12:154] mbim_read_thread is created
sh: can't create /sys/class/net/rmnet_mhi0/mbim/link_state: nonexistent directory
[04-02_04:14:12:156] system(echo 0 > /sys/class/net/rmnet_mhi0/mbim/link_state)=256
[04-02_04:14:12:185] system(ip address flush dev rmnet_mhi0)=0
[04-02_04:14:12:187] system(ip link set dev rmnet_mhi0 down)=0
[04-02_04:14:12:188] mbim_open_device()
[04-02_04:14:12:605] mbim_device_caps_query()
[04-02_04:14:12:610] DeviceId:     869710030002905
[04-02_04:14:12:610] HardwareInfo: 0
[04-02_04:14:12:610] mbim_set_radio_state( 1 )
[04-02_04:14:12:613] HwRadioState: 1, SwRadioState: 1
[04-02_04:14:12:613] mbim_subscriber_status_query()
[04-02_04:14:12:620] SubscriberReadyState NotInitialized -> Initialized 
[04-02_04:14:12:620] mbim_register_state_query()
[04-02_04:14:12:625] RegisterState Unknown -> Home 
[04-02_04:14:12:625] mbim_packet_service_query()
[04-02_04:14:12:629] PacketServiceState Unknown -> Attached 
[04-02_04:14:12:629] mbim_query_connect(sessionID=0)
[04-02_04:14:12:633] ActivationState Unknown -> Deactivated 
[04-02_04:14:12:633] mbim_set_connect(onoff=1, sessionID=0)
[   69.170666] net rmnet_mhi0: link_state 0x0 -> 0x1
[04-02_04:14:12:680] ActivationState Deactivated -> Activated 
[   69.177035] [I][mhi_netdev_open] Opened net dev interface
[04-02_04:14:12:680] mbim_ip_config(sessionID=0)
[04-02_04:14:12:683] < SessionId = 0
[04-02_04:14:12:683] < IPv4ConfigurationAvailable = 0xf
[04-02_04:14:12:683] < IPv6ConfigurationAvailable = 0x0
[04-02_04:14:12:683] < IPv4AddressCount = 0x1
[04-02_04:14:12:683] < IPv4AddressOffset = 0x3c
[04-02_04:14:12:683] < IPv6AddressCount = 0x0
[04-02_04:14:12:683] < IPv6AddressOffset = 0x0
[04-02_04:14:12:683] < IPv4 = 10.129.59.93/30
[04-02_04:14:12:683] < gw = 10.129.59.94
[04-02_04:14:12:683] < dns1 = 211.138.180.2
[04-02_04:14:12:683] < dns2 = 211.138.180.3
[04-02_04:14:12:683] < ipv4 mtu = 1500
sh: can't create /sys/class/net/rmnet_mhi0/mbim/link_state: nonexistent directory
[04-02_04:14:12:684] system(echo 1 > /sys/class/net/rmnet_mhi0/mbim/link_state)=256
[04-02_04:14:12:689] system(ip link set dev rmnet_mhi0 up)=0
[04-02_04:14:12:692] system(ip -4 address flush dev rmnet_mhi0)=0
[04-02_04:14:12:694] system(ip -4 address add 10.129.59.93/30 dev rmnet_mhi0)=0
[04-02_04:14:12:697] system(ip -4 route add default via 10.129.59.94 dev rmnet_mhi0)=0
[04-02_04:14:12:699] system(ip -4 link set dev rmnet_mhi0 mtu 1500)=0

root@OpenWrt:~# ifconfig rmnet_mhi0
rmnet_mhi0 Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          UP RUNNING NOARP  MTU:1500  Metric:1
          RX packets:99379 errors:0 dropped:0 overruns:0 frame:0
          TX packets:176569 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1528181052 (1.4 GiB)  TX bytes:62467192 (59.5 MiB)

root@OpenWrt:~# ifconfig rmnet_mhi0.1
rmnet_mhi0.1 Link encap:UNSPEC  HWaddr 02-50-F4-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.129.59.93  Mask:255.255.255.252
          inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link
          UP RUNNING NOARP  MTU:1500  Metric:1
          RX packets:1089360 errors:0 dropped:0 overruns:0 frame:0
          TX packets:176581 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1521449058 (1.4 GiB)  TX bytes:57525792 (54.8 MiB)

# adjust CPU load balancing
root@OpenWrt:~# echo 2 > /sys/class/net/rmnet_mhi0/queues/rx-0/rps_cpus 
root@OpenWrt:~# echo 4 > /sys/class/net/rmnet_mhi0.1/queues/rx-0/rps_cpus 
root@OpenWrt:~# echo 2000 > /proc/sys/net/core/netdev_max_backlog 
root@OpenWrt:~# cat /sys/class/net/rmnet_mhi0/queues/rx-0/rps_cpus
2
root@OpenWrt:~# cat /sys/class/net/rmnet_mhi0.1/queues/rx-0/rps_cpus
4
root@OpenWrt:~# cat /proc/sys/net/core/netdev_max_backlog
2000
