Peer configuration and DMA

Peer mode 0 disables operations; mode 1 enables transparent RMEM; mode 2 fetches a block into local memory and permits incoming bulk writes; mode 3 sends a block to remote memory and permits incoming bulk reads. Mirror relationships require complementary modes 2 and 3. Local and remote addresses are 32-bit bus addresses, not CPU pointers.

openenoc_endpoint_status_t openenoc_endpoint_peer_get_config(volatile const csr__endpoint_interface_t *endpoint, uint16_t peer_index, openenoc_endpoint_peer_config_t *config)

Read one peer mapping and access policy.

Parameters:
  • endpoint – In; required mapped, word-aligned endpoint-interface pointer.

  • peer_index – In; zero-based index smaller than the advertised peer count.

  • config – Out; required peer-configuration destination.

Returns:

OK; INVALID_ARGUMENT, OUT_OF_RANGE for an invalid peer index, or UNSUPPORTED when neither peer DMA nor RMEM is implemented.

Side effects:

Reads the selected peer CSRs.

openenoc_endpoint_status_t openenoc_endpoint_peer_set_config(volatile csr__endpoint_interface_t *endpoint, uint16_t peer_index, const openenoc_endpoint_peer_config_t *config)

Apply one peer mapping and access policy.

Parameters:
  • endpoint – In; required mapped, word-aligned endpoint-interface pointer.

  • peer_index – In; zero-based index smaller than the advertised peer count.

  • config – In; required peer mapping. Addresses/RMEM offset must be word-aligned; enabled regions must be nonempty and fit the 32-bit address spaces.

Returns:

OK; INVALID_ARGUMENT for invalid arguments, alignment, mode, overlapping transparent mappings, or multicast mirror-to-local target; OUT_OF_RANGE for peer index or region bounds; UNSUPPORTED for unavailable features; NOT_READY for pending commands or active local peer DMA.

Preconditions:

Transparent regions must fit RMEM, have a word-multiple size, and not overlap another transparent mapping. Local/remote users must be quiescent; idle alone does not prove incoming requests have stopped.

Side effects:

Temporarily disables the selected peer, writes mapping registers, then applies mode and IRQ enable.

openenoc_endpoint_status_t openenoc_endpoint_peer_dma_request(volatile csr__endpoint_interface_t *endpoint, uint16_t peer_index)

Submit a transfer of the configured peer region.

Parameters:
  • endpoint – In; required mapped, word-aligned endpoint-interface pointer.

  • peer_index – In; zero-based index smaller than the advertised peer count.

Returns:

OK; INVALID_ARGUMENT for an invalid endpoint pointer, non-mirror mode, zero block size or invalid configured fragment limit; OUT_OF_RANGE for peer index; UNSUPPORTED when peer DMA is absent; NOT_READY for pending commands or active local peer DMA.

Preconditions:

Capture previous completion state before submission. Keep peer mapping and buffers stable while pending or active.

Side effects:

Sets the peer request command without waiting for acceptance or completion.

openenoc_endpoint_status_t openenoc_endpoint_peer_get_status(volatile const csr__endpoint_interface_t *endpoint, uint16_t peer_index, openenoc_endpoint_peer_status_t *status)

Read local peer-DMA state and shared diagnostics.

Parameters:
  • endpoint – In; required mapped, word-aligned endpoint-interface pointer.

  • peer_index – In; zero-based index smaller than the advertised peer count.

  • status – Out; required destination for pending commands, idle/done, and sticky error/code.

Returns:

OK; INVALID_ARGUMENT, OUT_OF_RANGE for an invalid peer index, or UNSUPPORTED when neither peer DMA nor RMEM is implemented.

Side effects:

Reads the peer status; preserves commands and error state.

openenoc_endpoint_status_t openenoc_endpoint_peer_request_clear_error(volatile csr__endpoint_interface_t *endpoint, uint16_t peer_index)

Submit clearing of one shared peer error record.

Parameters:
  • endpoint – In; required mapped, word-aligned endpoint-interface pointer.

  • peer_index – In; zero-based index smaller than the advertised peer count.

Returns:

OK; INVALID_ARGUMENT, OUT_OF_RANGE for an invalid peer index, or UNSUPPORTED when neither peer DMA nor RMEM is implemented. NOT_READY when request or error-clear acknowledgement is pending.

Side effects:

Sets clear_error without waiting; preserves mode and IRQ enable. Hardware clearing preserves active work and done state; new failures win a simultaneous clear.

Public declarations

The maintained header below provides the exact public type and enum definitions.

Peer types
 1typedef enum {
 2    OPENENOC_ENDPOINT_PEER_DISABLED = 0,
 3    OPENENOC_ENDPOINT_PEER_TRANSPARENT_RMEM = 1,
 4    OPENENOC_ENDPOINT_PEER_MIRROR_TO_LOCAL = 2,
 5    OPENENOC_ENDPOINT_PEER_MIRROR_TO_REMOTE = 3
 6} openenoc_endpoint_peer_mode_t;
 7
 8typedef struct {
 9    openenoc_endpoint_mac_t mac_address;
10    uint32_t rmem_offset_bytes;
11    uint32_t local_address;
12    uint32_t remote_address;
13    uint32_t size_bytes;
14    openenoc_endpoint_peer_mode_t mode;
15    bool irq_enable;
16} openenoc_endpoint_peer_config_t;
17
18typedef struct {
19    bool request_pending;
20    bool clear_error_pending;
21    bool idle;
22    bool done;
23    bool error;
24    openenoc_endpoint_error_t error_code;
25} openenoc_endpoint_peer_status_t;
26