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 79850A046B for ; Tue, 25 Jun 2019 17:33:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BE901BA90; Tue, 25 Jun 2019 17:32:15 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 9C4AB1BA4D for ; Tue, 25 Jun 2019 17:32:07 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 08:32:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,416,1557212400"; d="scan'208";a="166711434" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.223.4]) by orsmga006.jf.intel.com with ESMTP; 25 Jun 2019 08:32:05 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, Abraham Tovar , Lukasz Krakowiak Date: Tue, 25 Jun 2019 16:31:54 +0100 Message-Id: <20190625153217.24301-6-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190625153217.24301-1-jasvinder.singh@intel.com> References: <20190528120553.2992-2-lukaszx.krakowiak@intel.com> <20190625153217.24301-1-jasvinder.singh@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 05/28] 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" Update 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 | 71 ++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index aea938899..22db212ed 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -294,6 +294,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) { @@ -640,31 +663,47 @@ rte_sched_port_config(struct rte_sched_port_params *params) return port; } -void -rte_sched_port_free(struct rte_sched_port *port) +static inline void +rte_sched_subport_free(struct rte_sched_subport *subport) { + uint32_t n_subport_queues; uint32_t qindex; - uint32_t n_queues_per_port; - /* Check user parameters */ - if (port == NULL) + if (subport == NULL) return; - n_queues_per_port = rte_sched_port_queues_per_port(port); + n_subport_queues = rte_sched_subport_queues(subport); /* 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); - - for (; qr != qw; qr = (qr + 1) & (qsize - 1)) - rte_pktmbuf_free(mbufs[qr]); + for (qindex = 0; qindex < n_subport_queues; qindex++) { + struct rte_mbuf **mbufs = + rte_sched_subport_qbase(subport, qindex); + uint16_t qsize = rte_sched_subport_qsize(subport, qindex); + if (qsize != 0) { + struct rte_sched_queue *queue = subport->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]); + } } - rte_bitmap_free(port->bmp); + rte_bitmap_free(subport->bmp); +} + +void +rte_sched_port_free(struct rte_sched_port *port) +{ + uint32_t i; + + /* Check user parameters */ + if (port == NULL) + return; + + for (i = 0; i < port->n_subports_per_port; i++) + rte_sched_subport_free(port->subports[i]); + rte_free(port); } -- 2.21.0