From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by dpdk.org (Postfix) with ESMTP id 9CAC5AFDA for ; Wed, 14 May 2014 18:26:20 +0200 (CEST) Received: by mail-pb0-f54.google.com with SMTP id jt11so1904674pbb.13 for ; Wed, 14 May 2014 09:26:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-type:content-disposition; bh=BZ5T0bRQ2fZWBczcj1hu6j/AyU+vfDx40Xld+t4RQ2Q=; b=SC6n8T82YlszDxqHCaiZAK8QM628spdDspOzqQwpBbh7Nb/oJAwdCjgoPNtSZSAzeB AMz/a3TmboKucVdAjzI1/cO9SEEWiv6IMX+h0e17pfsxKkCoCfuj8od8d4q0wdIW8kSg SYzm5Py1T5f6xGQsugS/hlvmiIiMnFShEMoqiDW1QVsBOvmNcL2YAmGqg+tt2KHhGRoL P+DCfesPJ3Xu8yEbpFcYC8dQ738oEDcHZB4nZH8OQVyMjzwrp26WXSGZRQZfTErmg/1Z rJ3kGDNLTY2AtuK1x3Tgc8z6ioDPlLjcUGxXuJ2MWVTvawKyZYaDrIUg2QP8BfSdBfHE HEZQ== X-Gm-Message-State: ALoCoQly2ZHcxTeUkPvg90urnrdneep3pyAsYoZcMdfgyFgmFfswz5CdccSYgYp47nCDQOYRdZ/p X-Received: by 10.68.160.163 with SMTP id xl3mr5694996pbb.39.1400084788015; Wed, 14 May 2014 09:26:28 -0700 (PDT) Received: from localhost (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id or4sm4335305pbb.17.2014.05.14.09.26.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 May 2014 09:26:27 -0700 (PDT) Message-Id: <20140514162626.262461494@networkplumber.org> User-Agent: quilt/0.61-1 Date: Wed, 14 May 2014 09:25:25 -0700 From: Stephen Hemminger To: dev@dpdk.org References: <20140514162524.113765980@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=sched-rte-malloc.patch Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 1/3] qos: use rte_zmalloc instead of memzone for allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 May 2014 16:26:21 -0000 The existing rte scheduler can only be safely configured once per port because a memory zone has a fixed size once it is created and can never be freed or change in size. This patch changes the scheduler to use rte_malloc instead. This allows for a port to be reconfigured by doing rte_sched_port_free followed rte_sched_port_config. The patch also removes the now unused name parameter from the port parameters structure. Signed-off-by: Stephen Hemminger --- app/test/test_sched.c | 2 -- lib/librte_sched/rte_sched.c | 29 ++++++----------------------- 2 files changed, 6 insertions(+), 25 deletions(-) --- a/lib/librte_sched/rte_sched.c 2014-05-14 09:01:15.085164140 -0700 +++ b/lib/librte_sched/rte_sched.c 2014-05-14 09:05:16.078491725 -0700 @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -306,11 +306,6 @@ rte_sched_port_check_params(struct rte_s return -1; } - /* name */ - if (params->name == NULL) { - return -2; - } - /* socket */ if ((params->socket < 0) || (params->socket >= RTE_MAX_NUMA_NODES)) { return -3; @@ -613,7 +608,6 @@ struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) { struct rte_sched_port *port = NULL; - const struct rte_memzone *mz = NULL; uint32_t mem_size, bmp_mem_size, n_queues_per_port, i; /* Check user parameters. Determine the amount of memory to allocate */ @@ -623,21 +617,10 @@ rte_sched_port_config(struct rte_sched_p } /* Allocate memory to store the data structures */ - mz = rte_memzone_lookup(params->name); - if (mz) { - /* Use existing memzone, provided that its size is big enough */ - if (mz->len < mem_size) { - return NULL; - } - } else { - /* Create new memzone */ - mz = rte_memzone_reserve(params->name, mem_size, params->socket, 0); - if (mz == NULL) { - return NULL; - } + port = rte_zmalloc("qos_params", mem_size, CACHE_LINE_SIZE); + if (port == NULL) { + return NULL; } - memset(mz->addr, 0, mem_size); - port = (struct rte_sched_port *) mz->addr; /* User parameters */ port->n_subports_per_port = params->n_subports_per_port; @@ -716,9 +699,9 @@ rte_sched_port_free(struct rte_sched_por if (port == NULL){ return; } + rte_bitmap_free(port->bmp); - - return; + rte_free(port); } static void --- a/app/test/test_sched.c 2014-05-14 09:08:34.067612152 -0700 +++ b/app/test/test_sched.c 2014-05-14 09:08:48.723695881 -0700 @@ -83,7 +83,6 @@ static struct rte_sched_pipe_params pipe }; static struct rte_sched_port_params port_param = { - .name = "port_0", .socket = 0, /* computed */ .rate = 0, /* computed */ .mtu = 1522, @@ -172,7 +171,6 @@ test_sched(void) port_param.socket = 0; port_param.rate = (uint64_t) 10000 * 1000 * 1000 / 8; - port_param.name = "port_0"; port = rte_sched_port_config(&port_param); VERIFY(port != NULL, "Error config sched port\n");