drivers/net/hyperv/rndis_filter.c
Source file repositories/reference/linux-study-clean/drivers/net/hyperv/rndis_filter.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/hyperv/rndis_filter.c- Extension
.c- Size
- 46836 bytes
- Lines
- 1642
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/ethtool.hlinux/kernel.hlinux/sched.hlinux/wait.hlinux/highmem.hlinux/slab.hlinux/io.hlinux/if_ether.hlinux/netdevice.hlinux/if_vlan.hlinux/nls.hlinux/vmalloc.hlinux/rtnetlink.hlinux/ucs2_string.hlinux/string.hhyperv_net.hnetvsc_trace.h
Detected Declarations
struct rndis_requestfunction put_rndis_requestfunction dump_rndis_messagefunction rndis_filter_send_requestfunction rndis_set_link_statefunction rndis_filter_receive_responsefunction rsc_add_datafunction rndis_filter_receive_datafunction rndis_filter_receivefunction rndis_filter_query_devicefunction rndis_query_hwcapsfunction rndis_filter_query_device_macfunction rndis_filter_set_device_macfunction rndis_filter_set_offload_paramsfunction rndis_set_rss_param_msgfunction rndis_filter_set_rss_paramfunction rndis_filter_query_device_link_statusfunction rndis_filter_query_link_speedfunction rndis_filter_set_packet_filterfunction rndis_set_multicastfunction rndis_filter_updatefunction rndis_filter_init_devicefunction netvsc_device_idlefunction rndis_filter_halt_devicefunction rndis_filter_open_devicefunction rndis_filter_close_devicefunction netvsc_sc_openfunction rndis_set_subchannelfunction rndis_netdev_set_hwcapsfunction rndis_get_friendly_namefunction rndis_filter_device_removefunction rndis_filter_openfunction rndis_filter_close
Annotated Snippet
struct rndis_request {
struct list_head list_ent;
struct completion wait_event;
struct rndis_message response_msg;
/*
* The buffer for extended info after the RNDIS response message. It's
* referenced based on the data offset in the RNDIS message. Its size
* is enough for current needs, and should be sufficient for the near
* future.
*/
u8 response_ext[RNDIS_EXT_LEN];
/* Simplify allocation by having a netvsc packet inline */
struct hv_netvsc_packet pkt;
struct rndis_message request_msg;
/*
* The buffer for the extended info after the RNDIS request message.
* It is referenced and sized in a similar way as response_ext.
*/
u8 request_ext[RNDIS_EXT_LEN];
};
static const u8 netvsc_hash_key[NETVSC_HASH_KEYLEN] = {
0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa
};
static struct rndis_device *get_rndis_device(void)
{
struct rndis_device *device;
device = kzalloc_obj(struct rndis_device);
if (!device)
return NULL;
spin_lock_init(&device->request_lock);
INIT_LIST_HEAD(&device->req_list);
INIT_WORK(&device->mcast_work, rndis_set_multicast);
device->state = RNDIS_DEV_UNINITIALIZED;
return device;
}
static struct rndis_request *get_rndis_request(struct rndis_device *dev,
u32 msg_type,
u32 msg_len)
{
struct rndis_request *request;
struct rndis_message *rndis_msg;
struct rndis_set_request *set;
unsigned long flags;
request = kzalloc_obj(struct rndis_request);
if (!request)
return NULL;
init_completion(&request->wait_event);
rndis_msg = &request->request_msg;
rndis_msg->ndis_msg_type = msg_type;
rndis_msg->msg_len = msg_len;
request->pkt.q_idx = 0;
/*
* Set the request id. This field is always after the rndis header for
* request/response packet types so we just used the SetRequest as a
* template
*/
set = &rndis_msg->msg.set_req;
set->req_id = atomic_inc_return(&dev->new_req_id);
/* Add to the request list */
spin_lock_irqsave(&dev->request_lock, flags);
list_add_tail(&request->list_ent, &dev->req_list);
spin_unlock_irqrestore(&dev->request_lock, flags);
return request;
}
static void put_rndis_request(struct rndis_device *dev,
struct rndis_request *req)
{
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/kernel.h`, `linux/sched.h`, `linux/wait.h`, `linux/highmem.h`, `linux/slab.h`, `linux/io.h`, `linux/if_ether.h`.
- Detected declarations: `struct rndis_request`, `function put_rndis_request`, `function dump_rndis_message`, `function rndis_filter_send_request`, `function rndis_set_link_state`, `function rndis_filter_receive_response`, `function rsc_add_data`, `function rndis_filter_receive_data`, `function rndis_filter_receive`, `function rndis_filter_query_device`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.