# bacnh85/quectel_linux_usb_driver architecture

> Architecture diagram of the GitHub repository bacnh85/quectel_linux_usb_driver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bacnh85/quectel_linux_usb_driver
- Repository: https://github.com/bacnh85/quectel_linux_usb_driver

## Overview

##### Project type and purpose
- This is a Linux kernel driver project providing USB-serial and QMI WWAN support for Quectel cellular modems (UCxx/EC2x/EGxx/EP06/EM06/BG96/AG35).
- It plugs into the USB core, registers against the generic “option” and “usbnet” subsystems, and exposes serial (ttyUSBx) and network (wwan0) interfaces to user space.

##### File structure
- Top level:
- LICENSE, README.md, Makefile – project metadata and build script
- Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide_V1.8.pdf – vendor guide
- Source under pseudo-kernel tree:
- drivers/net/usb/qmi_wwan.c – QMI-over-USB network driver
- drivers/net/usb/usbnet.c – generic USB-network support
- drivers/usb/serial/option.c – generic serial-over-USB driver
- drivers/usb/serial/qcserial.c – Quectel-specific serial bindings
- drivers/usb/serial/usb_wwan.c – USB WWAN helper definitions
- No user-space code: all is implemented as loadable kernel modules.

##### Insights from README
- Targets Ubuntu 16.04 with kernel 4.15.x.
- Build instructions use “make” and “make install” to place modules in /lib/modules/$(uname -r)/kernel/drivers/… and then modprobe them.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Hardware Layer
    subgraph "Hardware Layer"
        Modem["Quectel USB Modem"]:::hardware
        HostUSB["Host USB Controller\n(EHCI/XHCI)"]:::hardware
    end

    %% Kernel Space
    subgraph "Kernel Space"
        subgraph "Core Subsystems"
            USBCore["USB Core Subsystem"]:::kernel
            TTYLayer["TTY Layer\n(ttyUSBx)"]:::kernel
            NetStack["Network Stack\n(wwan0)"]:::kernel
        end
        subgraph "Loadable Modules"
            Option["option.ko"]:::module
            QCSerial["qcserial.ko"]:::module
            USBWWAN["usb_wwan.c + usb-wwan.h"]:::module
            USBNet["usbnet.ko"]:::module
            QMIWWAN["qmi_wwan.ko"]:::module
        end
        USBCore -->|enumeration| Option
        USBCore -->|enumeration| QCSerial
        QCSerial -->|serial data| TTYLayer
        Option -->|generic serial| TTYLayer
        USBCore -->|network packets| USBNet
        USBNet -->|usbnet core| QMIWWAN
        QMIWWAN -->|QMI messages| NetStack
    end

    %% User Space
    subgraph "User Space"
        PPPD["pppd / minicom"]:::user
        NM["NetworkManager"]:::user
        LibQMI["libqmi/qmicli"]:::user
        App["Custom Application"]:::user
    end
    TTYLayer -->|"serial chars"| PPPD
    TTYLayer -->|"serial chars"| App
    NetStack -->|"network packets"| NM
    NetStack -->|"QMI messages"| LibQMI
    LibQMI -->|"control"| App

    %% Build & Documentation
    subgraph "Build & Installation"
        Makefile["Makefile"]:::docs
        Modules[".ko Files"]:::docs
        Modprobe["insmod / modprobe"]:::docs
        Makefile -->|build| Modules
        Modules -->|install| Modprobe
    end
    subgraph "Documentation"
        README["README.md"]:::docs
        PDF["Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide_V1.8.pdf"]:::docs
        LICENSE["LICENSE"]:::docs
    end

    %% Data Flow from Hardware to Kernel
    Modem -->|USB packets| HostUSB
    HostUSB --> USBCore

    %% Click Events for component mappings
    click QMIWWAN "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/drivers/net/usb/qmi_wwan.c"
    click USBNet "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/drivers/net/usb/usbnet.c"
    click Option "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/drivers/usb/serial/option.c"
    click QCSerial "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/drivers/usb/serial/qcserial.c"
    click USBWWAN "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/drivers/usb/serial/usb_wwan.c"
    click USBWWAN "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/drivers/usb/serial/usb-wwan.h"
    click Makefile "https://github.com/bacnh85/quectel_linux_usb_driver/tree/master/Makefile"
    click README "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/README.md"
    click PDF "https://github.com/bacnh85/quectel_linux_usb_driver/blob/master/Quectel_WCDMA&LTE_Linux_USB_Driver_User_Guide_V1.8.pdf"
    click LICENSE "https://github.com/bacnh85/quectel_linux_usb_driver/tree/master/LICENSE"

    %% Styles
    classDef hardware fill:#FFE699,stroke:#cc9900
    classDef kernel fill:#CFE2F3,stroke:#6d9eeb
    classDef module fill:#D9EAD3,stroke:#6aa84f
    classDef user fill:#F4CCCC,stroke:#cc0000
    classDef docs fill:#EAD1DC,stroke:#a64d79
```
