-
-
Notifications
You must be signed in to change notification settings - Fork 188
uefi: add high-level TCP wrapper #1798
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
base: main
Are you sure you want to change the base?
Conversation
b692b35 to
e130f46
Compare
|
typically we mark PRs as draft when they wait to be rebased onto another PR - so I marked this PR as draft. Thanks for working on this and splitting this into multiple PRs! |
ebf20de to
dee28f7
Compare
05b5155 to
f547536
Compare
|
|
||
| impl Tcp4 { | ||
| /// See [Tcp4Protocol::configure]. | ||
| pub fn configure(&mut self, config: &ConfigData, options: Option<&ConfigOptions>) -> Result { |
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 just realize this fn duplicates a lot of Ip4Config2::ifup() . Should I just make Tcp4 take a NIC Handle that's already been configured like Http does?
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.
makes sense. in uefi, we prefer to hide lower-level details of UEFI from public API. Convenient high-level abstractions are very appreciated
327b902 to
7d9befe
Compare
|
#1797 is merged, please rebase |
|
@phip1611 I had to move on to a different task for a bit but I am not done with this PR. I plan on getting back to it soonish, but I can close it in the meantime if you prefer |
No worries. We can keep it open. As a rule of thumb, I'd like to close PRs that are inactive for 6 months. So you still have some time |
|
hi @JayKickliter |
Absolutely. We're using this in production. I'll prioritize |
7d9befe to
b51a482
Compare
|
I marked this PR ready for review |
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 for your contribution! You said you are using this in production? That's great!
Left a few remarks:
- Please streamline function documentation. There are other parts in the code that use that pattern already
- please list the error codes that can happen for each function (as listed in the UEFI spec)
I'd love if you have the capacity to add an integration test, but that could also be a follow-up.
| /// boot, print, println, | ||
| /// proto::network::tcp4::{AccessPoint, ConfigData, Tcp4, | ||
| /// Tcp4ServiceBinding, | ||
| /// }, |
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.
this looks broken?
| /// }, |
| unsafe { (self.0.configure)(self.this(), ptr::from_ref(&tcpv4_config_data) as *mut _) } | ||
| .to_result(); | ||
| // Maximum timeout of 10 seconds. | ||
| for _ in 0..9 { |
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.
| for _ in 0..9 { | |
| for _ in 0..10 { |
or
| for _ in 0..9 { | |
| for _ in 0..=9 { |
or
| for _ in 0..9 { | |
| // Maximum timeout of 9 seconds. |
I prefer (A)
| Ok(()) | ||
| } | ||
|
|
||
| /// See [Tcp4Protocol::transmit]. |
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.
| /// See [Tcp4Protocol::transmit]. | |
| /// See [`Tcp4Protocol::transmit`]. |
also same as above, please follow our documentation template
| pub struct Tcp4(pub Tcp4Protocol); | ||
|
|
||
| impl Tcp4 { | ||
| /// See [Tcp4Protocol::configure]. |
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.
| /// See [Tcp4Protocol::configure]. | |
| /// <high-level description in one sentence> | |
| /// | |
| /// <if helpful, additional comments> | |
| /// | |
| /// | |
| /// See [`Tcp4Protocol::configure`] for more details. | |
| /// | |
| /// # Arguments | |
| /// | |
| /// - `config`: the [`ConfigData`] to apply <if needed more explanation> | |
| /// - `options`: the optional [`ConfigOptions`] <if needed more explanation> | |
| /// | |
| /// # Errors | |
| /// | |
| /// - [`Status::INVALID_PARAMETER`]: if .... | |
| /// - <the other error status codes that can be returned here> |
| res | ||
| } | ||
|
|
||
| /// See [`Tcp4Protocol::connect`]. |
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.
Please adapt this to the style I've mentioned above.
We are not 100% consistent with this yet in the code base unfortunately, but new code should follow that pattern
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.
Copy, thanks for the review
| Ok(rx_data_len) | ||
| } | ||
|
|
||
| /// Receives data from the remote connection. On success, returns |
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.
same
| /// Receives data from the remote connection. On success, returns | ||
| /// the number of bytes read. | ||
| /// | ||
| /// See [Tcp4Protocol::receive]. |
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.
| /// See [Tcp4Protocol::receive]. | |
| /// See [`Tcp4Protocol::receive`]. |
| self.receive_vectored(&[buf]) | ||
| } | ||
|
|
||
| /// Receives the exact number of bytes required to fill `buf`. |
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.
same
| pub struct Tcp4ServiceBinding(ServiceBindingProtocol); | ||
|
|
||
| impl Tcp4ServiceBinding { | ||
| /// Create TCPv4 Protocol Handle. |
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.
same as above, please follow our doc template
| } | ||
| } | ||
|
|
||
| /// Destroy TCPv4 Protocol Handle. |
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.
same as above, please follow our doc template
This is PR 2 of 2 adding TCP to uefi-rs, and is a replacement for #1779. Note that this PR contains the commits from #1797 and will need to rebased before merging.
TODO before merging
uefi-rawrelative path dep inuefi/Cargo.tomlto point to publusheduefi-rawcrate.Checklist