net/vmw_vsock/vmci_transport_notify_qstate.c
Source file repositories/reference/linux-study-clean/net/vmw_vsock/vmci_transport_notify_qstate.c
File Facts
- System
- Linux kernel
- Corpus path
net/vmw_vsock/vmci_transport_notify_qstate.c- Extension
.c- Size
- 11370 bytes
- Lines
- 431
- 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_handle_readfunction vmci_transport_handle_wrotefunction vsock_block_update_write_windowfunction vmci_transport_send_read_notificationfunction vmci_transport_notify_pkt_socket_initfunction vmci_transport_notify_pkt_socket_destructfunction vmci_transport_notify_pkt_poll_infunction vmci_transport_notify_pkt_poll_outfunction vmci_transport_notify_pkt_recv_initfunction vmci_transport_notify_pkt_recv_pre_blockfunction vmci_transport_notify_pkt_recv_post_dequeuefunction vmci_transport_notify_pkt_send_initfunction vmci_transport_notify_pkt_send_post_enqueuefunction vmci_transport_notify_pkt_handle_pktfunction vmci_transport_notify_pkt_process_requestfunction vmci_transport_notify_pkt_process_negotiatefunction vmci_transport_notify_pkt_recv_pre_dequeuefunction vmci_transport_notify_pkt_send_pre_blockfunction vmci_transport_notify_pkt_send_pre_enqueue
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);
/* 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;
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;
}
return retval;
}
static void
vmci_transport_handle_read(struct sock *sk,
struct vmci_transport_packet *pkt,
bool bottom_half,
struct sockaddr_vm *dst, struct sockaddr_vm *src)
{
sk->sk_write_space(sk);
}
static void
vmci_transport_handle_wrote(struct sock *sk,
struct vmci_transport_packet *pkt,
bool bottom_half,
struct sockaddr_vm *dst, struct sockaddr_vm *src)
{
vsock_data_ready(sk);
}
static void vsock_block_update_write_window(struct sock *sk)
{
struct vsock_sock *vsk = vsock_sk(sk);
if (PKT_FIELD(vsk, write_notify_window) < vmci_trans(vsk)->consume_size)
PKT_FIELD(vsk, write_notify_window) =
min(PKT_FIELD(vsk, write_notify_window) + PAGE_SIZE,
vmci_trans(vsk)->consume_size);
}
static int vmci_transport_send_read_notification(struct sock *sk)
{
struct vsock_sock *vsk;
bool sent_read;
unsigned int retries;
int err;
vsk = vsock_sk(sk);
sent_read = false;
retries = 0;
err = 0;
if (vmci_transport_notify_waiting_write(vsk)) {
/* Notify the peer that we have read, retrying the send on
* failure up to our maximum value. XXX For now we just log
* the failure, but later we should schedule a work item to
* handle the resend until it succeeds. That would require
* keeping track of work items in the vsk and cleaning them up
* upon socket close.
*/
while (!(vsk->peer_shutdown & RCV_SHUTDOWN) &&
!sent_read &&
retries < VMCI_TRANSPORT_MAX_DGRAM_RESENDS) {
err = vmci_transport_send_read(sk);
if (err >= 0)
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_handle_read`, `function vmci_transport_handle_wrote`, `function vsock_block_update_write_window`, `function vmci_transport_send_read_notification`, `function vmci_transport_notify_pkt_socket_init`, `function vmci_transport_notify_pkt_socket_destruct`, `function vmci_transport_notify_pkt_poll_in`, `function vmci_transport_notify_pkt_poll_out`, `function vmci_transport_notify_pkt_recv_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.