From: Stephen Hemminger Date: Wed, 14 May 2014 16:25:25 +0000 (-0700) Subject: sched: use malloc instead of memzone for allocation X-Git-Tag: spdx-start~10799 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3d349a1d35edf2cbd6c16a2c65967ec964469654;p=dpdk.git sched: use malloc instead of memzone for allocation 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 Acked-by: Thomas Monjalon --- diff --git a/app/test/test_sched.c b/app/test/test_sched.c index 0de5b1c6a6..206eb5b3dd 100644 --- a/app/test/test_sched.c +++ b/app/test/test_sched.c @@ -83,7 +83,6 @@ static struct rte_sched_pipe_params pipe_profile[] = { }; 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"); diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 24e8bdf197..b50148425c 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -306,11 +306,6 @@ rte_sched_port_check_params(struct rte_sched_port_params *params) 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_port_params *params) } /* 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_port *port) if (port == NULL){ return; } + rte_bitmap_free(port->bmp); - - return; + rte_free(port); } static void