-
Notifications
You must be signed in to change notification settings - Fork 13.5k
std: sys: net: uefi: tcp4: Implement write #141532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@rustbot label +O-UEFI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits but this looks reasonable to me. @nicholasbishop would you mind double checking since this is UEFI?
let protocol = self.protocol.as_ptr(); | ||
let mut token = tcp4::IoToken { | ||
completion_token, | ||
packet: tcp4::IoTokenPacket { tx_data: &mut tx_data as *mut _ as *mut _ }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packet: tcp4::IoTokenPacket { tx_data: ptr::from_mut(&mut tx_data).cast::<whatever>() },
What casts are needed? tx_data
should be tcp4::TransmitData
, and that looks like what is expected in https://docs.rs/r-efi/latest/r_efi/protocols/tcp4/union.IoTokenPacket.html.
Also, isn't rx_data
missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What casts are needed? tx_data should be tcp4::TransmitData, and that looks like what is expected in https://docs.rs/r-efi/latest/r_efi/protocols/tcp4/union.IoTokenPacket.html.
Well, tcp4::TransmitData
is a const generic. tcp4::IoTokenPacket
takes ZST (tcp4::TransmitData<0>
). So we are casting tcp4::TransmitData<1>
to tcp4::TransmitData<0>
.
Also, isn't rx_data missing?
It's a union.
|
||
let fragment = tcp4::FragmentData { | ||
fragment_length: data_len, | ||
fragment_buffer: buf.as_ptr() as *mut _, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit to make the cast obvious (especially since it includes a mutability change)
fragment_buffer: buf.as_ptr().cast::<c_void>().cast_mut()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result<usize> { | ||
unsupported() | ||
pub fn write_vectored(&self, buf: &[IoSlice<'_>]) -> io::Result<usize> { | ||
// FIXME: UEFI does support vectored write, so implment that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implment -> implement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
let evt = unsafe { self.create_evt() }?; | ||
let completion_token = | ||
tcp4::CompletionToken { event: evt.as_ptr(), status: Status::SUCCESS }; | ||
let data_len = crate::cmp::min(u32::MAX as u64, buf.len() as u64) as u32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading correctly that this is truncating the buffer length to a u32
? If so, might be clearer as:
let data_len = u32::try_from(buf.len()).unwrap_or(u32::MAX);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
let mut token = tcp4::IoToken { | ||
completion_token, | ||
packet: tcp4::IoTokenPacket { | ||
tx_data: &mut tx_data as *mut tcp4::TransmitData<1> as *mut tcp4::TransmitData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this casting could be simplified:
tx_data: (&raw mut tx_data).cast::<tcp4::TransmitData<0>>(),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
A blocking implementation of tcp4 write. Signed-off-by: Ayush Singh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@bors r+ rollup |
std: sys: net: uefi: tcp4: Implement write A blocking implementation of tcp4 write.
Rollup of 9 pull requests Successful merges: - #141532 (std: sys: net: uefi: tcp4: Implement write) - #143085 (Port `#[non_exhaustive]` to the new attribute parsing infrastructure) - #143298 (`tests/ui`: A New Order [23/N]) - #143372 (Remove names_imported_by_glob_use query.) - #143386 (Assign dependency bump PRs to me) - #143406 (Remove some unnecessary `unsafe` in VecCache) - #143408 (mbe: Gracefully handle macro rules that end after `=>`) - #143414 (remove special-casing of boxes from match exhaustiveness/usefulness analysis) - #143444 (clean up GVN TypeId test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - #141532 (std: sys: net: uefi: tcp4: Implement write) - #143085 (Port `#[non_exhaustive]` to the new attribute parsing infrastructure) - #143372 (Remove names_imported_by_glob_use query.) - #143386 (Assign dependency bump PRs to me) - #143406 (Remove some unnecessary `unsafe` in VecCache) - #143408 (mbe: Gracefully handle macro rules that end after `=>`) - #143414 (remove special-casing of boxes from match exhaustiveness/usefulness analysis) - #143444 (clean up GVN TypeId test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #141532 - Ayush1325:uefi-tcp4-send, r=tgross35 std: sys: net: uefi: tcp4: Implement write A blocking implementation of tcp4 write.
A blocking implementation of tcp4 write.