MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / process_rx

Method process_rx

virtio-devices/src/vsock/device.rs:128–170  ·  view source on GitHub ↗

Walk the driver-provided RX queue buffers and attempt to fill them up with any data that we have pending.

(&mut self)

Source from the content-addressed store, hash-verified

126 /// have pending.
127 ///
128 fn process_rx(&mut self) -> result::Result<bool, Error> {
129 debug!("vsock: epoll_handler::process_rx()");
130
131 let mut used_descs = false;
132
133 while let Some(mut desc_chain) = self.queues[0].pop_descriptor_chain(self.mem.memory()) {
134 let used_len = match VsockPacket::from_rx_virtq_head(
135 &mut desc_chain,
136 self.access_platform.as_deref(),
137 ) {
138 Ok(mut pkt) => {
139 if self.backend.write().unwrap().recv_pkt(&mut pkt).is_ok() {
140 match pkt.commit_hdr(&*self.mem.memory()) {
141 Ok(()) => pkt.hdr().len() as u32 + pkt.len(),
142 Err(err) => {
143 warn!(
144 "vsock: Error writing packet header to guest memory: \
145 {err:?}. Discarding the package."
146 );
147 0
148 }
149 }
150 } else {
151 // We are using a consuming iterator over the virtio buffers, so, if we can't
152 // fill in this buffer, we'll need to undo the last iterator step.
153 self.queues[0].go_to_previous_position();
154 break;
155 }
156 }
157 Err(e) => {
158 warn!("vsock: RX queue error: {e:?}");
159 0
160 }
161 };
162
163 self.queues[0]
164 .add_used(desc_chain.memory(), desc_chain.head_index(), used_len)
165 .map_err(Error::QueueAddUsed)?;
166 used_descs = true;
167 }
168
169 Ok(used_descs)
170 }
171
172 /// Walk the driver-provided TX queue buffers, package them up as vsock packets, and send them to
173 /// the backend for processing.

Callers 4

handle_eventMethod · 0.45
handle_rx_tap_eventMethod · 0.45
handle_eventMethod · 0.45
test_rxq_eventFunction · 0.45

Calls 6

memoryMethod · 0.80
commit_hdrMethod · 0.80
hdrMethod · 0.80
recv_pktMethod · 0.45
writeMethod · 0.45
lenMethod · 0.45

Tested by 1

test_rxq_eventFunction · 0.36