What is "rmnet_gsi" USB function? I was looking through the init files from my boot image and noticed a USB flag labelled rmnet_gsi here.
What does this setting do?
Example source:
on property:sys.usb.config=diag,serial_cdev,rmnet_gsi,adb &amp;&amp; property:sys.usb.configfs=1
    start adbd
In addition to Android's generic USB functions (like adb, mtp, rndis), rmnet_gsi is a hardware specific USB function which exposes some of your GSM/3G/LTE modem's functionality to PC over USB. Usually this is not something an ordinary user is concerned about.

It involves understanding two core concepts:

How Android communicates with modem/BP (which lives on SoC along with other core components including CPU/AP and RAM) for internet data. Communication with modem/BP occurs e.g. through serial channels (like USB or UART, as other components of SoC do: QDL 9006/9008, EDL, fastboot etc.), or by sharing a reserved area of RAM (e.g. SMD or SSM in case of Qualcomm).
How different USB functions of Android Composite Gadget driver (which is an extension to Linux kernel's USB Gadget API) are used to expose Android in USB device mode to a USB host like PC. Different USB functions (like UMS, MTP, RNDIS etc.) can be configured and switched using sysfs or configfs.

On devices with Qualcomm's MSM SoCs (like USB modems or phones), RmNet (Remote Network) is modem's data transfer and control protocol which exposes Ethernet like IP interface as data channel and uses QMI as control protocol. Generic Software Interface (GSI, which replaced BAM) transports communication with IPA core of the modem. Internet Packet Accelerator (IPA) is an IP packet processor which performs better than CPU/AP for this specific purpose.
IPA/GSI can be used with different tethering protocols including RNDIS, RmNet and DIAG/DPL/QDSS. In order to access BP from PC (e.g. to use internet or do some debugging), Android kernel includes USB functions (like rmnet_gsi) for these protocols in order to expose them through USB (so that Android device appears like a USB modem). Proprietary protocols may not be used without vendor provided software. E.g. on Android devices we have RIL and cnd - vendor provided daemons - to communicate with BP. However there are open source tools like QCSuper which can talk Diag protocol over /dev/diag.

RESOURCES:

Gadget RmNet
Qualcomm MSM specific device drivers
Qualcomm Kernel