Skip to content

prov/efa: emulated write Rma protocols refactor - #12843

Open
charlesstoll wants to merge 5 commits into
ofiwg:mainfrom
charlesstoll:rma_refactor
Open

charlesstoll wants to merge 5 commits into
ofiwg:mainfrom
charlesstoll:rma_refactor

Conversation

@charlesstoll

Copy link
Copy Markdown
Contributor

This patch series contains:

  1. a few small pre-work changes to prepare for the shared emulated write protocol engine code
  2. adds the emulate write protocol engine
  3. adds the eager rtw protocol to the new framework

@charlesstoll
charlesstoll force-pushed the rma_refactor branch 3 times, most recently from a054004 to 63e5433 Compare September 17, 2026 16:57
Comment thread prov/efa/src/rdm/efa_rdm_proto.c Outdated

if (selected_proto->can_use_protocol(
txe, req_pkt_type, header_flags, iface)) {
txe, req_pkt_type, header_flags, iface, false)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's ok for now but this shouldn't always be set to false. See the logic here

err = efa_rdm_ep_use_p2p_for_mr(ep, txe->desc[0]);
if (err < 0)
return err;
use_p2p = err;

I'm implementing it when I add the read based protocols

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed this so it doesn't hardcode false

Comment thread prov/efa/src/rdm/efa_rdm_proto.c Outdated
* do not need it.
*/
if (use_p2p &&
txe->total_len >= g_efa_hmem_info[iface].min_read_write_size &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this also be gated behind a wants_mr or needs_mr field?

You could also skip this for now/fix it later because the eager protocol will never register anyway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

* @param[in,out] pkt_entry received EFA_RDM_EAGER_RTW packet
*
*/
void efa_rdm_pke_handle_eager_rtw_recv(struct efa_rdm_pke *pkt_entry)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we rename the prefixes? e.g. efa_rdm_proto_handle_eager_rtw_recv_completion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread prov/efa/src/rdm/efa_rdm_pke_rtw.c Outdated
* negative libfabric error code on error.
*/
static inline
ssize_t efa_rdm_pke_init_rtw_common(struct efa_rdm_pke *pkt_entry,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you move this function to prov/efa/src/rdm/protocols as well and make it static inline? Not worth a function call just to set a few fields

You could make a new header efa_rdm_proto_write.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

ep->efa_rnr_queued_pkt_cnt >
0);

pkt_entry = efa_rdm_pke_alloc(ep, ep->efa_tx_pkt_pool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is now commonized in my PR. I can replace it with the common code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sounds good. if yours goes in first though, then I'll make sure to commonize when I rebase

*/
*pke_send_flags = (txe->fi_flags & FI_MORE) ? FI_MORE : 0;

assert(ep->efa_max_outstanding_tx_ops - ep->efa_outstanding_tx_ops -

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should return -FI_EAGAIN instead of asserting when TX credits are exhausted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checking for TX credits should happen in the earlier function

// Handle case when there are no TX packets available
available_tx_pkts = efa_rdm_ep_get_available_tx_pkts(ep);
if (OFI_UNLIKELY(available_tx_pkts == 0)) {
err = -FI_EAGAIN;
goto out;
}

So an assert here should work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added the assert back, added a credit check in the previous function.

for (i = 0; efa_rdm_emulated_write_protocols[i] != NULL; ++i) {
selected_proto = efa_rdm_emulated_write_protocols[i];

req_pkt_type = efa_rdm_proto_req_pkt_type(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The type helper efa_rdm_proto_req_pkt_type forces a non-DC packet whenever FI_INJECT is present, even if FI_DELIVERY_COMPLETE is also requested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch. fixed it in my patch and fixed the common send code as well in a new patch (still this pr).

@sunkuamzn sunkuamzn Sep 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think FI_INJECT + FI_DELIVERY_COMPLETE is a valid combination. FI_DELIVERY_COMPLETE necessarily requires the buffer to be available for retransmits. It can be implemented with a copy but that defeats the point of FI_INJECT - which is to send the data as quickly as possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed... again :)

@charlesstoll
charlesstoll force-pushed the rma_refactor branch 3 times, most recently from 363953f to 0cbe348 Compare September 18, 2026 15:41
@charlesstoll

Copy link
Copy Markdown
Contributor Author

bot:aws:retest

yinliaws
yinliaws previously approved these changes Sep 18, 2026
* 0 on success.
* negative libfabric error code on failure
*/
static ssize_t efa_rdm_proto_eager_write_init_dc_rtw(struct efa_rdm_pke *pkt_entry,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: would it be easier to follow if the TX and RX functions were put together? Right now, the order is

efa_rdm_proto_eager_write_init_rtw
efa_rdm_pke_handle_eager_rtw_send_completion
efa_rdm_proto_eager_write_proc_rtw
efa_rdm_proto_eager_write_handle_rtw_recv
efa_rdm_proto_eager_write_init_dc_rtw
efa_rdm_proto_eager_write_handle_dc_rtw_recv

How about

/* TX path functions */
efa_rdm_proto_eager_write_init_rtw
efa_rdm_proto_eager_write_init_dc_rtw
efa_rdm_pke_handle_eager_rtw_send_completion

/* RX path functions */
efa_rdm_proto_eager_write_proc_rtw
efa_rdm_proto_eager_write_handle_rtw_recv
efa_rdm_proto_eager_write_handle_dc_rtw_recv

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

A behavior-preserving cleanup ahead of routing emulated writes through
the protocol interface.

Rename the efa_rdm_proto callback can_use_protocol_for_send to
can_use_protocol. The same callback is used by both the send and the
emulated write paths, so the send-specific name is misleading.

Signed-off-by: Charles Stoll <stollcha@amazon.com>
Add the write engine on the efa_rdm_proto interface. The main differences
from send is that the write engine must first check if the device is write
capable and use that, if possible.

Modifies the protocol selection API to pass in use_p2p since this is
relevant to the write protocols.

No write protocol is registered yet, so selection always returns none
and every write falls through to the existing selection.

Signed-off-by: Charles Stoll <stollcha@amazon.com>
(cherry picked from commit 925bf12)
Implement the emulated eager write protocol on the efa_rdm_proto
interface and register it in the emulated write protocol list.

Signed-off-by: Charles Stoll <stollcha@amazon.com>
(cherry picked from commit 92984d4)
Move the shared RTW payload helper into a static inline in
protocols/efa_rdm_proto_write.h so the eager write protocol and the
LONGCTS RTW path share it without exporting it from the pke layer, and
rename it to efa_rdm_proto_write_rtw_pke_init_common to match the
protocol interface naming.

Signed-off-by: Charles Stoll <stollcha@amazon.com>
Group the eager write helpers into TX and RX path sections. No
functional change.

Signed-off-by: Charles Stoll <stollcha@amazon.com>
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