Skip to content

Commit

Permalink
fix: delete transmit_wait
Browse files Browse the repository at this point in the history
  • Loading branch information
hky1999 committed Nov 12, 2023
1 parent 8f288ea commit 20fe99c
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/aarch64/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn virtio_net<T: Transport>(transport: T) {
pkt_len,
&buf[hdr_len..hdr_len + pkt_len]
);
net.transmit_wait(&buf[..hdr_len + pkt_len])
net.send(&buf[..hdr_len + pkt_len])
.expect("failed to send");
info!("virtio-net test finished");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/riscv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn virtio_net<T: Transport>(transport: T) {
pkt_len,
&buf[hdr_len..hdr_len + pkt_len]
);
net.transmit_wait(&buf[..hdr_len + pkt_len])
net.send(&buf[..hdr_len + pkt_len])
.expect("failed to send");
info!("virtio-net test finished");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/riscv/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<T: Transport> TxToken for VirtioTxToken<T> {
let mut tx_buf = dev.new_tx_buffer(len);
let result = f(tx_buf.packet_mut());
trace!("SEND {} bytes: {:02X?}", len, tx_buf.packet());
dev.transmit_wait(tx_buf).unwrap();
dev.send(tx_buf).unwrap();
result
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/x86_64/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn virtio_net<T: Transport>(transport: T) {
pkt_len,
&buf[hdr_len..hdr_len + pkt_len]
);
net.transmit_wait(&buf[..hdr_len + pkt_len])
net.send(&buf[..hdr_len + pkt_len])
.expect("failed to send");
info!("virtio-net test finished");
}
Expand Down
6 changes: 0 additions & 6 deletions src/device/net/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ impl<H: Hal, T: Transport, const QUEUE_SIZE: usize> VirtIONet<H, T, QUEUE_SIZE>
TxBuffer(vec![0; buf_len])
}

/// Sends a [`TxBuffer`] to the network, and blocks until the request
/// completed. Returns number of bytes transmitted.
pub fn transmit_wait(&mut self, tx_buf: TxBuffer) -> Result<usize> {
self.inner.transmit_wait(tx_buf.packet())
}

/// Sends a [`TxBuffer`] to the network, and blocks until the request
/// completed.
pub fn send(&mut self, tx_buf: TxBuffer) -> Result {
Expand Down
15 changes: 0 additions & 15 deletions src/device/net/dev_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,6 @@ impl<H: Hal, T: Transport, const QUEUE_SIZE: usize> VirtIONetRaw<H, T, QUEUE_SIZ
Ok((NET_HDR_SIZE, packet_len))
}

/// Transmits a packet to the network, and blocks until the request
/// completed. Returns number of bytes transmitted.
///
/// The caller needs to fill the `tx_buf` with a header by calling
/// [`fill_buffer_header`] before transmission.
///
/// [`fill_buffer_header`]: Self::fill_buffer_header
pub fn transmit_wait(&mut self, tx_buf: &[u8]) -> Result<usize> {
let token = unsafe { self.transmit_begin(tx_buf)? };
while self.poll_transmit().is_none() {
core::hint::spin_loop();
}
unsafe { self.transmit_complete(token, tx_buf) }
}

/// Sends a packet to the network, and blocks until the request
/// completed.
pub fn send(&mut self, tx_buf: &[u8]) -> Result {
Expand Down

0 comments on commit 20fe99c

Please sign in to comment.