Skip to content
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

[dv/dpi] tcp_server_create changes #25646

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kwalker27
Copy link
Contributor

I'm proposing to make it a fatal error to fail to open the listening socket rather than simply continuing the simulation after printing an error. My rationale is that it would be better to intentionally open the socket (and optionally provide a mechanism to make the port unique, as was recently done for jtagdpi), instead of the current "best effort" approach.

The changes here: (1) make the socket setup synchronous to the create() call while leaving the processing on a dedicated pthread and (2) assert if the setup fails.

I expect there could be fallout from this (in CI sim jobs, for example) since dmidpi currently starts the server unconditionally and uses a static port number (set via SV parameter). So, I expect there might need to be additional changes after discussion whether folks consider whether this policy change is sensible or not.

When the tcp_server is unable to create its listening socket, the
simulation now exits. Previously, an error would be printed but the
simulation would continue. Clients like dmidpi and jtagdpi should only
call tcp_server_create if there's a chance a client will connect, and
if the listening port number is being selected to avoid conflict with
other processes on the same machine.

Signed-off-by: Kip Walker <[email protected]>
@kwalker27 kwalker27 requested a review from a team as a code owner December 13, 2024 16:36
@kwalker27 kwalker27 requested review from hcallahan-lowrisc, rswarbrick, Razer6 and andreaskurth and removed request for a team December 13, 2024 16:36
The listening socket creation is made synchronous with the
tcp_server_create call, while the processing of socket events is still
handled on a dedicated thread.

Signed-off-by: Kip Walker <[email protected]>
@kwalker27 kwalker27 changed the title tcp_server_create changes [dv/dpi] tcp_server_create changes Dec 13, 2024
@kwalker27
Copy link
Contributor Author

The regression failure is what I was afraid of:

dmi0: Failed to bind socket: Address already in use (98)
dmi0: Unable to create TCP server on port 44853

So, I'd like to hear opinions on whether the suggestion in this PR makes sense or not - and if it does, this work needs to be deferred until (1) dmidpi server setup is made conditional and (2) port collisions are avoided somehow (dynamic port selection?) when a dmidpi client needs to be supported.

In the current state of things, a user running a single sim on a local machine gets the benefit of dmidpi always being there. But as soon as multiple sims are running on a machine, you can't guarantee the process you want to connect to will have won the race to claim the port. So I'd argue some sort of change to the usage model is worth considering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant