Ejemplo n.º 1
0
static uint16_t
aesni_mb_pmd_enqueue_burst(void *queue_pair, struct rte_mbuf **bufs,
		uint16_t nb_bufs)
{
	struct rte_mbuf_offload *ol;

	struct aesni_mb_session *sess;
	struct aesni_mb_qp *qp = queue_pair;

	JOB_AES_HMAC *job = NULL;

	int i, processed_jobs = 0;

	for (i = 0; i < nb_bufs; i++) {
		ol = rte_pktmbuf_offload_get(bufs[i], RTE_PKTMBUF_OL_CRYPTO);
		if (unlikely(ol == NULL)) {
			qp->qp_stats.enqueue_err_count++;
			goto flush_jobs;
		}

		sess = get_session(qp, &ol->op.crypto);
		if (unlikely(sess == NULL)) {
			qp->qp_stats.enqueue_err_count++;
			goto flush_jobs;
		}

		job = process_crypto_op(qp, bufs[i], &ol->op.crypto, sess);
		if (unlikely(job == NULL)) {
			qp->qp_stats.enqueue_err_count++;
			goto flush_jobs;
		}

		/* Submit Job */
		job = (*qp->ops->job.submit)(&qp->mb_mgr);

		/*
		 * If submit returns a processed job then handle it,
		 * before submitting subsequent jobs
		 */
		if (job)
			processed_jobs += handle_completed_jobs(qp, job);
	}

	if (processed_jobs == 0)
		goto flush_jobs;
	else
		qp->qp_stats.enqueued_count += processed_jobs;
		return i;

flush_jobs:
	/*
	 * If we haven't processed any jobs in submit loop, then flush jobs
	 * queue to stop the output stalling
	 */
	job = (*qp->ops->job.flush_job)(&qp->mb_mgr);
	if (job)
		qp->qp_stats.enqueued_count += handle_completed_jobs(qp, job);

	return i;
}
Ejemplo n.º 2
0
// Handle trigger requests from the sim module ("sim_exec.trigger")
static void trigger_cb (flux_t *h,
                        flux_msg_handler_t *w,
                        const flux_msg_t *msg,
                        void *arg)
{
    json_t *o = NULL;
    const char *json_str = NULL;
    double next_termination = -1;
    zhash_t *job_hash = NULL;
    ctx_t *ctx = (ctx_t *)arg;

    if (flux_msg_get_string (msg, &json_str) < 0 || json_str == NULL
        || !(o = Jfromstr (json_str))) {
        flux_log (h, LOG_ERR, "%s: bad message", __FUNCTION__);
        return;
    }

    // Logging
    flux_log (h,
              LOG_DEBUG,
              "received a trigger (sim_exec.trigger: %s",
              json_str);

    // Handle the trigger
    ctx->sim_state = json_to_sim_state (o);
    handle_queued_events (ctx);
#if SIMEXEC_IO
    job_hash = determine_all_min_bandwidth (ctx->rdl, ctx->running_jobs);
#endif
    advance_time (ctx, job_hash);
    handle_completed_jobs (ctx);
    next_termination =
        determine_next_termination (ctx, ctx->sim_state->sim_time, job_hash);
    set_event_timer (ctx, "sim_exec", next_termination);
    send_reply_request (h, module_name, ctx->sim_state);

    // Cleanup
    free_simstate (ctx->sim_state);
    ctx->sim_state = NULL;
    Jput (o);
    zhash_destroy (&job_hash);
}