static void *psl(void *ptr) { struct cxl_afu_h *afu = (struct cxl_afu_h *)ptr; while (status.psl_state != PSL_DONE) { if (status.psl_state == PSL_INIT) { psl_signal_afu_model (status.event); status.psl_state = PSL_RUNNING; } if (status.cmd.request==AFU_REQUEST) { if (psl_job_control (status.event, status.cmd.code, status.cmd.addr) == PSL_SUCCESS) { #ifdef DEBUG printf ("Job 0x%02x\n", status.cmd.code); #endif /* #ifdef DEBUG */ if (status.cmd.code == PSL_JOB_RESET) status.cmd.request = AFU_RESET; else status.cmd.request = AFU_PENDING; continue; } } else if (status.mmio.request == AFU_REQUEST) { if (status.mmio.rnw) { if (psl_mmio_read (status.event, status.mmio.dw, status.mmio.addr, status.mmio.desc) == PSL_SUCCESS) { #ifdef DEBUG printf ("MMIO Read %d\n", status.mmio.addr); #endif /* #ifdef DEBUG */ status.mmio.request = AFU_PENDING; continue; } } else { if (psl_mmio_write (status.event, status.mmio.dw, status.mmio.addr, status.mmio.data, status.mmio.desc) == PSL_SUCCESS) { #ifdef DEBUG printf ("MMIO Write %d\n", status.mmio.addr); #endif /* #ifdef DEBUG */ status.mmio.request = AFU_PENDING; continue; } } } if (!(rand() % RESP_RANDOMIZER)) push_resp(); psl_signal_afu_model (status.event); if (psl_get_afu_events (status.event) > 0) { handle_psl_events (afu); } } pthread_exit(NULL); }
void send_job(struct job *job) { struct job_event *event; // Test for valid job if ((job == NULL) || (job->job == NULL)) return; // Client disconnected if (job->job->state == PSLSE_DONE) { event = job->job; job->job = event->_next; free(event); return; } // Test for valid job event = job->job; if ((event == NULL) || (event->state == PSLSE_PENDING)) return; // Attempt to send job to AFU if (psl_job_control(job->afu_event, event->code, event->addr) == PSL_SUCCESS) { event->state = PSLSE_PENDING; // Change job state if (event->code == PSL_JOB_RESET) *(job->psl_state) = PSLSE_RESET; // DEBUG debug_job_send(job->dbg_fp, job->dbg_id, event->code); } }