25 static int _get_remote_progress(
int proc,
photonLedger buf);
28 int entry_size,
int prefix) {
31 new = (
struct photon_rdma_ledger_t *)((uintptr_t)ledger_buffer +
33 sizeof(
struct photon_rdma_ledger_t));
35 memset(
new, 0,
sizeof(
struct photon_rdma_ledger_t));
37 new->entries = ledger_buffer;
42 memset(new->entries, 0, entry_size * num_entries);
47 new->entry_size = entry_size;
48 new->num_entries = num_entries;
51 new->acct.event_prefix = prefix;
61 uint64_t curr, tail, rcur;
64 int rc = be->tx_size_left(proc);
70 rcur = sync_load(&l->acct.rcur, SYNC_RELAXED);
71 curr = sync_load(&l->curr, SYNC_RELAXED);
72 tail = sync_load(&l->tail, SYNC_RELAXED);
73 if ((curr - tail) >= l->num_entries) {
77 if ((curr - rcur) >= (l->num_entries)) {
79 _get_remote_progress(proc, l);
80 dbg_trace(
"No new ledger entry until receiver catches up...");
83 }
while (!sync_cas(&l->curr, &curr, curr+1, SYNC_RELAXED, SYNC_RELAXED));
85 if ((curr - rcur) == (
int)(l->num_entries * 0.8)) {
87 _get_remote_progress(proc, l);
90 return curr & (l->num_entries - 1);
93 static int _get_remote_progress(
int proc,
photonLedger buf) {
103 dbg_err(
"Failure getting event");
108 if (sync_cas(&buf->acct.rloc, &rloc, 1, SYNC_ACQUIRE, SYNC_RELAXED)) {
110 dbg_trace(
"Fetching remote ledger (%d) curr at rcur: %llu", proc, buf->acct.rcur);
113 sizeof(
struct photon_rdma_ledger_t) + offsetof(struct photon_rdma_ledger_t, prog);
115 cookie = ( (uint64_t)buf->acct.event_prefix<<32) | proc;
117 rc = be->rdma_get(proc, (uintptr_t)&buf->acct.rcur, rmt_addr,
sizeof(buf->acct.rcur),
120 dbg_err(
"RDMA GET for remote ledger progress counter failed");
photonLedger photon_rdma_ledger_create_reuse(void *ledger_buffer, int num_entries, int entry_size, int prefix)
photonBufferHandle shared_storage
#define PHOTON_LEDG_SSIZE(c, s)
struct photon_req_t * photonRequest
ProcessInfo * photon_processes
#define PHOTON_ERROR
Error code, general error.
#define PHOTON_OK
Photon success code.
int photon_rdma_ledger_get_next(int proc, photonLedger l)
struct photon_rdma_ledger_t * photonLedger
#define PHOTON_EVENT_ERROR
#define PHOTON_CID_RECV_ENTRY_SIZE
int __photon_try_one_event(photonRequest *rreq)
void photon_rdma_ledger_free(photonLedger ledger)