1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
8 #include <rte_string_fns.h>
11 #include "rte_eth_softnic_internals.h"
14 softnic_swq_init(struct pmd_internals *p)
16 TAILQ_INIT(&p->swq_list);
22 softnic_swq_free(struct pmd_internals *p)
25 struct softnic_swq *swq;
27 swq = TAILQ_FIRST(&p->swq_list);
31 TAILQ_REMOVE(&p->swq_list, swq, node);
32 rte_ring_free(swq->r);
38 softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p)
40 struct softnic_swq *swq, *tswq;
42 RTE_TAILQ_FOREACH_SAFE(swq, &p->swq_list, node, tswq) {
43 if ((strncmp(swq->name, "RXQ", strlen("RXQ")) == 0) ||
44 (strncmp(swq->name, "TXQ", strlen("TXQ")) == 0))
47 TAILQ_REMOVE(&p->swq_list, swq, node);
48 rte_ring_free(swq->r);
54 softnic_swq_find(struct pmd_internals *p,
57 struct softnic_swq *swq;
62 TAILQ_FOREACH(swq, &p->swq_list, node)
63 if (strcmp(swq->name, name) == 0)
70 softnic_swq_create(struct pmd_internals *p,
72 struct softnic_swq_params *params)
74 char ring_name[NAME_SIZE];
75 struct softnic_swq *swq;
77 unsigned int flags = RING_F_SP_ENQ | RING_F_SC_DEQ;
79 /* Check input params */
81 softnic_swq_find(p, name) ||
87 snprintf(ring_name, sizeof(ring_name), "%s_%s",
91 r = rte_ring_create(ring_name,
100 swq = calloc(1, sizeof(struct softnic_swq));
107 strlcpy(swq->name, name, sizeof(swq->name));
110 /* Node add to list */
111 TAILQ_INSERT_TAIL(&p->swq_list, swq, node);