net/vmw_vsock/vmci_transport_notify.c
Source file repositories/reference/linux-study-clean/net/vmw_vsock/vmci_transport_notify.c
File Facts
- System
- Linux kernel
- Corpus path
net/vmw_vsock/vmci_transport_notify.c- Extension
.c- Size
- 18251 bytes
- Lines
- 673
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/socket.hlinux/stddef.hnet/sock.hvmci_transport_notify.h
Detected Declarations
function Copyrightfunction vmci_transport_notify_waiting_readfunction vmci_transport_handle_waiting_readfunction vmci_transport_handle_waiting_writefunction vmci_transport_handle_readfunction send_waiting_readfunction send_waiting_writefunction vmci_transport_send_read_notificationfunction vmci_transport_handle_wrotefunction vmci_transport_notify_pkt_socket_initfunction vmci_transport_notify_pkt_socket_destructfunction vmci_transport_notify_pkt_poll_outfunction vmci_transport_notify_pkt_recv_initfunction vmci_transport_notify_pkt_recv_pre_blockfunction vmci_transport_notify_pkt_recv_pre_dequeuefunction vmci_transport_notify_pkt_recv_post_dequeuefunction vmci_transport_notify_pkt_send_initfunction vmci_transport_notify_pkt_send_pre_blockfunction vmci_transport_notify_pkt_send_pre_enqueuefunction vmci_transport_notify_pkt_send_post_enqueuefunction vmci_transport_notify_pkt_handle_pktfunction vmci_transport_notify_pkt_process_requestfunction vmci_transport_notify_pkt_process_negotiate
Annotated Snippet
if (PKT_FIELD(vsk, write_notify_window) < PAGE_SIZE) {
PKT_FIELD(vsk, write_notify_window) =
PKT_FIELD(vsk, write_notify_min_window);
} else {
PKT_FIELD(vsk, write_notify_window) -= PAGE_SIZE;
if (PKT_FIELD(vsk, write_notify_window) <
PKT_FIELD(vsk, write_notify_min_window))
PKT_FIELD(vsk, write_notify_window) =
PKT_FIELD(vsk, write_notify_min_window);
}
}
notify_limit = vmci_trans(vsk)->consume_size -
PKT_FIELD(vsk, write_notify_window);
#else
notify_limit = 0;
#endif
/* For now we ignore the wait information and just see if the free
* space exceeds the notify limit. Note that improving this function
* to be more intelligent will not require a protocol change and will
* retain compatibility between endpoints with mixed versions of this
* function.
*
* The notify_limit is used to delay notifications in the case where
* flow control is enabled. Below the test is expressed in terms of
* free space in the queue: if free_space > ConsumeSize -
* write_notify_window then notify An alternate way of expressing this
* is to rewrite the expression to use the data ready in the receive
* queue: if write_notify_window > bufferReady then notify as
* free_space == ConsumeSize - bufferReady.
*/
retval = vmci_qpair_consume_free_space(vmci_trans(vsk)->qpair) >
notify_limit;
#ifdef VSOCK_OPTIMIZATION_FLOW_CONTROL
if (retval) {
/*
* Once we notify the peer, we reset the detected flag so the
* next wait will again cause a decrease in the window size.
*/
PKT_FIELD(vsk, peer_waiting_write_detected) = false;
}
#endif
return retval;
#else
return true;
#endif
}
static bool vmci_transport_notify_waiting_read(struct vsock_sock *vsk)
{
#if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY)
if (!PKT_FIELD(vsk, peer_waiting_read))
return false;
/* For now we ignore the wait information and just see if there is any
* data for our peer to read. Note that improving this function to be
* more intelligent will not require a protocol change and will retain
* compatibility between endpoints with mixed versions of this
* function.
*/
return vmci_qpair_produce_buf_ready(vmci_trans(vsk)->qpair) > 0;
#else
return true;
#endif
}
static void
vmci_transport_handle_waiting_read(struct sock *sk,
struct vmci_transport_packet *pkt,
bool bottom_half,
struct sockaddr_vm *dst,
struct sockaddr_vm *src)
{
#if defined(VSOCK_OPTIMIZATION_WAITING_NOTIFY)
struct vsock_sock *vsk;
vsk = vsock_sk(sk);
PKT_FIELD(vsk, peer_waiting_read) = true;
memcpy(&PKT_FIELD(vsk, peer_waiting_read_info), &pkt->u.wait,
sizeof(PKT_FIELD(vsk, peer_waiting_read_info)));
if (vmci_transport_notify_waiting_read(vsk)) {
bool sent;
if (bottom_half)
sent = vmci_transport_send_wrote_bh(dst, src) > 0;
else
Annotation
- Immediate include surface: `linux/types.h`, `linux/socket.h`, `linux/stddef.h`, `net/sock.h`, `vmci_transport_notify.h`.
- Detected declarations: `function Copyright`, `function vmci_transport_notify_waiting_read`, `function vmci_transport_handle_waiting_read`, `function vmci_transport_handle_waiting_write`, `function vmci_transport_handle_read`, `function send_waiting_read`, `function send_waiting_write`, `function vmci_transport_send_read_notification`, `function vmci_transport_handle_wrote`, `function vmci_transport_notify_pkt_socket_init`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.