drivers/usb/gadget/function/rndis.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/function/rndis.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/function/rndis.c- Extension
.c- Size
- 29481 bytes
- Lines
- 1190
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/moduleparam.hlinux/kernel.hlinux/errno.hlinux/idr.hlinux/list.hlinux/proc_fs.hlinux/slab.hlinux/seq_file.hlinux/netdevice.hasm/io.hasm/byteorder.hlinux/unaligned.hu_rndis.hrndis.h
Detected Declarations
function gen_ndis_query_respfunction gen_ndis_set_respfunction rndis_init_responsefunction rndis_query_responsefunction rndis_set_responsefunction rndis_reset_responsefunction rndis_keepalive_responsefunction rndis_indicate_status_msgfunction rndis_signal_connectfunction rndis_signal_disconnectfunction rndis_uninitfunction rndis_set_host_macfunction rndis_msg_parserfunction rndis_get_nrfunction rndis_put_nrfunction rndis_deregisterfunction rndis_set_param_devfunction rndis_set_param_vendorfunction rndis_set_param_mediumfunction rndis_add_hdrfunction rndis_free_responsefunction rndis_rm_hdrfunction rndis_proc_showfunction rndis_proc_writefunction rndis_proc_openexport rndis_signal_connectexport rndis_signal_disconnectexport rndis_uninitexport rndis_set_host_macexport rndis_msg_parserexport rndis_registerexport rndis_deregisterexport rndis_set_param_devexport rndis_set_param_vendorexport rndis_set_param_mediumexport rndis_add_hdrexport rndis_free_responseexport rndis_get_next_responseexport rndis_rm_hdr
Annotated Snippet
if (params->dev) {
*outbuf = cpu_to_le32(params->dev->mtu);
retval = 0;
}
break;
/* mandatory */
case RNDIS_OID_GEN_LINK_SPEED:
if (rndis_debug > 1)
pr_debug("%s: RNDIS_OID_GEN_LINK_SPEED\n", __func__);
if (params->media_state == RNDIS_MEDIA_STATE_DISCONNECTED)
*outbuf = cpu_to_le32(0);
else
*outbuf = cpu_to_le32(params->speed);
retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE:
pr_debug("%s: RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__);
if (params->dev) {
*outbuf = cpu_to_le32(params->dev->mtu);
retval = 0;
}
break;
/* mandatory */
case RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE:
pr_debug("%s: RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__);
if (params->dev) {
*outbuf = cpu_to_le32(params->dev->mtu);
retval = 0;
}
break;
/* mandatory */
case RNDIS_OID_GEN_VENDOR_ID:
pr_debug("%s: RNDIS_OID_GEN_VENDOR_ID\n", __func__);
*outbuf = cpu_to_le32(params->vendorID);
retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_VENDOR_DESCRIPTION:
pr_debug("%s: RNDIS_OID_GEN_VENDOR_DESCRIPTION\n", __func__);
if (params->vendorDescr) {
length = strlen(params->vendorDescr);
memcpy(outbuf, params->vendorDescr, length);
} else {
outbuf[0] = 0;
}
retval = 0;
break;
case RNDIS_OID_GEN_VENDOR_DRIVER_VERSION:
pr_debug("%s: RNDIS_OID_GEN_VENDOR_DRIVER_VERSION\n", __func__);
/* Created as LE */
*outbuf = rndis_driver_version;
retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_CURRENT_PACKET_FILTER:
pr_debug("%s: RNDIS_OID_GEN_CURRENT_PACKET_FILTER\n", __func__);
*outbuf = cpu_to_le32(*params->filter);
retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE:
pr_debug("%s: RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__);
*outbuf = cpu_to_le32(RNDIS_MAX_TOTAL_SIZE);
retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_MEDIA_CONNECT_STATUS:
if (rndis_debug > 1)
pr_debug("%s: RNDIS_OID_GEN_MEDIA_CONNECT_STATUS\n", __func__);
*outbuf = cpu_to_le32(params->media_state);
retval = 0;
break;
case RNDIS_OID_GEN_PHYSICAL_MEDIUM:
pr_debug("%s: RNDIS_OID_GEN_PHYSICAL_MEDIUM\n", __func__);
*outbuf = cpu_to_le32(0);
retval = 0;
break;
/* The RNDIS specification is incomplete/wrong. Some versions
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/errno.h`, `linux/idr.h`, `linux/list.h`, `linux/proc_fs.h`, `linux/slab.h`.
- Detected declarations: `function gen_ndis_query_resp`, `function gen_ndis_set_resp`, `function rndis_init_response`, `function rndis_query_response`, `function rndis_set_response`, `function rndis_reset_response`, `function rndis_keepalive_response`, `function rndis_indicate_status_msg`, `function rndis_signal_connect`, `function rndis_signal_disconnect`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.