My embedded linux board has usb-net gadget functionality. From my host computer I am able to establish ethernet over usb connectivity. I am trying to understand how the different layers of the usb gadget subsystem layers work together.
In the device tree, I can see the platform specific udc driver and in the kernel configuration I can see the USB Gadget and Ethernet Gadget support being enabled in the kernel drivers. So as I understand the g_ether driver gets built-in part of the kernel.
What configuration creates the usb gadget interface and endpoint and links it to the upper layer driver (g_ether) and creates the usb-net gadget ethernet interface ? Where to define the usb class function of the gadget and load a different upper layer driver ?
I am running version 5.10.36 kernel on my system. After some research and study, this is what I know so far. So during linux kernel build, I have following option setup in menuconfig.
Symbol: USB_ETH [=m]
Prompt: Ethernet Gadget (with CDC Ethernet support)
Defined at drivers/usb/gadget/Kconfig:628
Depends on: <choice> && NET
Location:
-> Kernel configuration
-> Device Drivers
-> USB support (USB_SUPPORT [=y])
-> USB Gadget Support (USB_GADGET [=y])
-> USB Gadget Drivers (<choice> [=y])
This configuration gives a predefined USB net gadget interface with CDC ethernet support and required end-point configuration. This driver is g_ether. The end point configuration is predefined in the file
drivers->usb->gadget->function->f_ecm.c
configFS can be used to configure a custom usb gadget interface from the user-space level.