4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/queue.h>
42 #include <rte_memory.h>
43 #include <rte_memzone.h>
44 #include <rte_launch.h>
46 #include <rte_eal_memconfig.h>
47 #include <rte_per_lcore.h>
48 #include <rte_lcore.h>
49 #include <rte_memory.h>
50 #include <rte_atomic.h>
51 #include <rte_branch_prediction.h>
53 #include <rte_string_fns.h>
55 #include "eal_private.h"
60 const char* rte_tailq_names[RTE_MAX_TAILQ] = {
61 #define rte_tailq_elem(idx, name) name,
62 #include <rte_tailq_elem.h>
65 struct rte_tailq_head *
66 rte_eal_tailq_lookup(const char *name)
69 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
74 for (i = 0; i < RTE_MAX_TAILQ; i++) {
75 if (rte_tailq_names[i] == NULL)
77 if (!strncmp(name, rte_tailq_names[i], RTE_TAILQ_NAMESIZE-1))
78 return &mcfg->tailq_head[i];
84 inline struct rte_tailq_head *
85 rte_eal_tailq_lookup_by_idx(const unsigned tailq_idx)
87 struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
89 if (tailq_idx >= RTE_MAX_TAILQ) {
90 RTE_LOG(ERR, EAL, "%s(): No more room in config\n", __func__);
94 return &mcfg->tailq_head[tailq_idx];
98 rte_dump_tailq(FILE *f)
100 struct rte_mem_config *mcfg;
103 mcfg = rte_eal_get_configuration()->mem_config;
105 rte_rwlock_read_lock(&mcfg->qlock);
106 for (i=0; i < RTE_MAX_TAILQ; i++) {
107 const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
108 const struct rte_tailq_entry_head *head = &tailq->tailq_head;
110 fprintf(f, "Tailq %u: qname:<%s>, tqh_first:%p, tqh_last:%p\n", i,
111 (rte_tailq_names[i] != NULL ? rte_tailq_names[i]:"nil"),
112 head->tqh_first, head->tqh_last);
114 rte_rwlock_read_unlock(&mcfg->qlock);
118 rte_eal_tailqs_init(void)
121 struct rte_mem_config *mcfg = NULL;
123 RTE_BUILD_BUG_ON(RTE_MAX_TAILQ < RTE_TAILQ_NUM);
125 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
126 mcfg = rte_eal_get_configuration()->mem_config;
127 for (i = 0; i < RTE_MAX_TAILQ; i++)
128 TAILQ_INIT(&mcfg->tailq_head[i].tailq_head);