From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id BBF041AEE8 for ; Fri, 8 Sep 2017 20:08:00 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Sep 2017 11:07:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,362,1500966000"; d="scan'208";a="149766872" Received: from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.) ([10.123.72.111]) by fmsmga006.fm.intel.com with ESMTP; 08 Sep 2017 11:07:59 -0700 From: Gage Eads To: dev@dpdk.org Cc: harry.van.haaren@intel.com, jerin.jacon@caviumnetworks.com Date: Fri, 8 Sep 2017 13:07:52 -0500 Message-Id: <1504894072-15735-1-git-send-email-gage.eads@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] event/sw: allow fwd and rel when out of credits X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 18:08:01 -0000 When forwarding or releasing events, the operation would fail if the port has 0 inflight credits and cannot acquire more, or the inflight count exceeds the port's new event threshold. This patch fixes that by counting the number of new events in the burst, and applying the credit and new event threshold checks accordingly. Signed-off-by: Gage Eads --- drivers/event/sw/sw_evdev_worker.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/event/sw/sw_evdev_worker.c b/drivers/event/sw/sw_evdev_worker.c index d76d3d5..b3b3b17 100644 --- a/drivers/event/sw/sw_evdev_worker.c +++ b/drivers/event/sw/sw_evdev_worker.c @@ -85,14 +85,18 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num) struct sw_port *p = port; struct sw_evdev *sw = (void *)p->sw; uint32_t sw_inflights = rte_atomic32_read(&sw->inflights); - - if (unlikely(p->inflight_max < sw_inflights)) - return 0; + int new = 0; if (num > PORT_ENQUEUE_MAX_BURST_SIZE) num = PORT_ENQUEUE_MAX_BURST_SIZE; - if (p->inflight_credits < num) { + for (i = 0; i < num; i++) + new += (ev[i].op == RTE_EVENT_OP_NEW); + + if (unlikely(new > 0 && p->inflight_max < sw_inflights)) + return 0; + + if (p->inflight_credits < new) { /* check if event enqueue brings port over max threshold */ uint32_t credit_update_quanta = sw->credit_update_quanta; if (sw_inflights + credit_update_quanta > sw->nb_events_limit) @@ -101,7 +105,7 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num) rte_atomic32_add(&sw->inflights, credit_update_quanta); p->inflight_credits += (credit_update_quanta); - if (p->inflight_credits < num) + if (p->inflight_credits < new) return 0; } -- 2.7.4