From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id F190AA045E for ; Tue, 28 May 2019 14:09:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DAE6C1B995; Tue, 28 May 2019 14:08:22 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 5C26C1B94A for ; Tue, 28 May 2019 14:08:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 May 2019 05:08:13 -0700 X-ExtLoop1: 1 Received: from lkrakowx-mobl.ger.corp.intel.com ([10.103.104.99]) by fmsmga001.fm.intel.com with ESMTP; 28 May 2019 05:08:12 -0700 From: Lukasz Krakowiak To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org, Jasvinder Singh , Abraham Tovar , Lukasz Krakowiak Date: Tue, 28 May 2019 14:05:31 +0200 Message-Id: <20190528120553.2992-6-lukaszx.krakowiak@intel.com> X-Mailer: git-send-email 2.19.2.windows.1 In-Reply-To: <20190528120553.2992-1-lukaszx.krakowiak@intel.com> References: <20190528120553.2992-1-lukaszx.krakowiak@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 05/27] sched: update port free api 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jasvinder Singh Update the scheduler port free api implementation to allow configuration flexiblity for pipe traffic classes and queues, and subport level configuration of the pipe parameters. Signed-off-by: Jasvinder Singh Signed-off-by: Abraham Tovar Signed-off-by: Lukasz Krakowiak --- lib/librte_sched/rte_sched.c | 61 ++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 8f11b4597..39a6165e3 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -316,6 +316,29 @@ rte_sched_port_queues_per_subport(struct rte_sched_port *port) #endif +static inline uint32_t +rte_sched_subport_queues(struct rte_sched_subport *subport) +{ + return RTE_SCHED_QUEUES_PER_PIPE * subport->n_subport_pipes; +} + +static inline struct rte_mbuf ** +rte_sched_subport_qbase(struct rte_sched_subport *subport, uint32_t qindex) +{ + uint32_t pindex = qindex >> 4; + uint32_t qpos = qindex & 0xF; + + return (subport->queue_array + pindex * + subport->qsize_sum + subport->qsize_add[qpos]); +} + +static inline uint16_t +rte_sched_subport_qsize(struct rte_sched_subport *subport, uint32_t qindex) +{ + uint32_t qpos = qindex & 0xF; + return subport->qsize[qpos]; +} + static inline uint32_t rte_sched_port_queues_per_port(struct rte_sched_port *port) { @@ -647,28 +670,40 @@ rte_sched_port_config(struct rte_sched_port_params *params) void rte_sched_port_free(struct rte_sched_port *port) { - uint32_t qindex; - uint32_t n_queues_per_port; + uint32_t n_subport_queues; + uint32_t qindex, i; /* Check user parameters */ if (port == NULL) return; - n_queues_per_port = rte_sched_port_queues_per_port(port); + for (i = 0; i < port->n_subports_per_port; i++) { + struct rte_sched_subport *s = port->subports[i]; - /* Free enqueued mbufs */ - for (qindex = 0; qindex < n_queues_per_port; qindex++) { - struct rte_mbuf **mbufs = rte_sched_port_qbase(port, qindex); - uint16_t qsize = rte_sched_port_qsize(port, qindex); - struct rte_sched_queue *queue = port->queue + qindex; - uint16_t qr = queue->qr & (qsize - 1); - uint16_t qw = queue->qw & (qsize - 1); + if (s == NULL) + continue; + + n_subport_queues = rte_sched_subport_queues(s); + + /* Free enqueued mbufs */ + for (qindex = 0; qindex < n_subport_queues; qindex++) { + struct rte_mbuf **mbufs = + rte_sched_subport_qbase(s, qindex); + uint16_t qsize = rte_sched_subport_qsize(s, qindex); + if (qsize != 0) { + struct rte_sched_queue *queue = + s->queue + qindex; + uint16_t qr = queue->qr & (qsize - 1); + uint16_t qw = queue->qw & (qsize - 1); + + for (; qr != qw; qr = (qr + 1) & (qsize - 1)) + rte_pktmbuf_free(mbufs[qr]); + } + } - for (; qr != qw; qr = (qr + 1) & (qsize - 1)) - rte_pktmbuf_free(mbufs[qr]); + rte_bitmap_free(s->bmp); } - rte_bitmap_free(port->bmp); rte_free(port); } -- 2.20.1