Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared core functionality for messages #149

Merged
merged 10 commits into from
Jul 27, 2019
Merged
2 changes: 1 addition & 1 deletion onvm/onvm_nflib/onvm_common.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ get_sem_name(unsigned id) {

static inline int
whether_wakeup_client(struct onvm_nf *nf, struct nf_wakeup_info *nf_wakeup_info) {
if (rte_ring_count(nf->rx_q) < PKT_WAKEUP_THRESHOLD)
if (rte_ring_count(nf->rx_q) < PKT_WAKEUP_THRESHOLD && rte_ring_count(nf->msg_q) == 0)
dennisafa marked this conversation as resolved.
Show resolved Hide resolved
return 0;

/* Check if its already woken up */
Expand Down
13 changes: 8 additions & 5 deletions onvm/onvm_nflib/onvm_nflib.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,14 @@ onvm_nflib_thread_main_loop(void *arg) {

start_time = rte_get_tsc_cycles();
for (;rte_atomic16_read(&nf_local_ctx->keep_running) && rte_atomic16_read(&main_nf_local_ctx->keep_running);) {
/* Possibly sleep if in shared core mode, otherwise continue */
if (ONVM_NF_SHARE_CORES) {
if (unlikely(rte_ring_count(nf->rx_q) == 0) && likely(rte_ring_count(nf->msg_q) == 0)) {
rte_atomic16_set(nf->shared_core.sleep_state, 1);
sem_wait(nf->shared_core.nf_mutex);
}
}

nb_pkts_added =
onvm_nflib_dequeue_packets((void **)pkts, nf_local_ctx, nf->function_table->pkt_handler);

Expand Down Expand Up @@ -908,12 +916,7 @@ onvm_nflib_dequeue_packets(void **pkts, struct onvm_nf_local_ctx *nf_local_ctx,
/* Dequeue all packets in ring up to max possible. */
nb_pkts = rte_ring_dequeue_burst(nf->rx_q, pkts, PACKET_READ_SIZE, NULL);

/* Possibly sleep if in shared core mode, otherwise return */
if (unlikely(nb_pkts == 0)) {
if (ONVM_NF_SHARE_CORES) {
rte_atomic16_set(nf->shared_core.sleep_state, 1);
sem_wait(nf->shared_core.nf_mutex);
}
return 0;
}

Expand Down