Skip to content

Modified generate_initiator_request - #12

Open
CourtneyDrant wants to merge 1 commit into
OpenPRoT:mainfrom
CourtneyDrant:api-openprot
Open

Modified generate_initiator_request #12
CourtneyDrant wants to merge 1 commit into
OpenPRoT:mainfrom
CourtneyDrant:api-openprot

Conversation

@CourtneyDrant

Copy link
Copy Markdown
Collaborator

Creates a cleaner interface for use in Open-Prot.

/// Sets the MCTP message-type byte at `msg_buf[0]` and writes the PLDM
/// request starting at `msg_buf[1]`.
///
/// Returns `Ok(0)` when no request is pending (nothing to send).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From fd_progress it seems, as if Ok(0) can have two meanings:

  1. The fd_state specific handlers returned a result = 0. That means, that the handlers (fd_progress_download, pldm_fd_progress_verify, pldm_fd_progress_apply) returned a 0.
  2. If a response is not received in T1, cancel the update and transition to idle

In the second case, is a silent cancel the correct handling of a failed update?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't implemented T1 timeouts yet. Can we make this a github issue and track it in there?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who should make the issue? can you link it here?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually, can we change the contract to something like:

Some(n) = transmit msg_buf[..n]
None = nothing due, poll again
Err(UpdateCancelled) = update died

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#13

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually, can we change the contract to something like:

Some(n) = transmit msg_buf[..n] None = nothing due, poll again Err(UpdateCancelled) = update died

Aren't the errors handle by fd_progress(payload)? and .map_err(MsgHandlerError::Util)?? Do we need another match?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No extra match needed — the problem is that the T1 cancel path isn't an error. It's already implemented (fd_context.rs:661-674) and returns Ok(0), so it becomes None, same as "verify still in progress" (fd_context.rs:948). The caller can't tell a running update from a dead one.

Keep #13 open for the T1/T2 timestamp work, but in this PR make the T1-cancel branch return an error (e.g. UpdateCancelled) so None has exactly one meaning: nothing due, poll again.

@chrysh

chrysh commented Aug 14, 2026

Copy link
Copy Markdown

This is potentially an API breaking change. Do we already have any consumers (here or openprot) that would need updating?

/// Sets the MCTP message-type byte at `msg_buf[0]` and writes the PLDM
/// request starting at `msg_buf[1]`.
///
/// Returns `Ok(0)` when no request is pending (nothing to send).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who should make the issue? can you link it here?

/// request starting at `msg_buf[1]`.
///
/// Returns `Ok(0)` when no request is pending (nothing to send).
/// Returns `Ok(n)` where `n` is the total number of bytes written to

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update doc (and examples and test code, if there are any)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only consumer is run_terminus.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What needs updating here? Do you need me to mention errors returned on fd_progress or construct_mctp_pldm_msg? That is where errors are returned.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function returns Ok(Some(n)) now instead of Ok(n)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Returns section above still documents Ok(0)/Ok(n) — update it to describe Some(n)/None.

/// Sets the MCTP message-type byte at `msg_buf[0]` and writes the PLDM
/// request starting at `msg_buf[1]`.
///
/// Returns `Ok(0)` when no request is pending (nothing to send).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually, can we change the contract to something like:

Some(n) = transmit msg_buf[..n]
None = nothing due, poll again
Err(UpdateCancelled) = update died

Comment thread pldm-interface/src/cmd_interface.rs Outdated
/// request starting at `msg_buf[1]`.
///
/// Returns `Ok(0)` when no request is pending (nothing to send).
/// Returns `Ok(n)` where `n` is the total number of bytes written to

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function returns Ok(Some(n)) now instead of Ok(n)

/// request starting at `msg_buf[1]`.
///
/// Returns `Ok(0)` when no request is pending (nothing to send).
/// Returns `Ok(n)` where `n` is the total number of bytes written to

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the doc consistent with the code? Is the total number of bytes written pldm_len or msg_buf length or so?

/// Sets the MCTP message-type byte at `msg_buf[0]` and writes the PLDM
/// request starting at `msg_buf[1]`.
///
/// Returns `Ok(0)` when no request is pending (nothing to send).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No extra match needed — the problem is that the T1 cancel path isn't an error. It's already implemented (fd_context.rs:661-674) and returns Ok(0), so it becomes None, same as "verify still in progress" (fd_context.rs:948). The caller can't tell a running update from a dead one.

Keep #13 open for the T1/T2 timestamp work, but in this PR make the T1-cancel branch return an error (e.g. UpdateCancelled) so None has exactly one meaning: nothing due, poll again.

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.

3 participants