1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
8 #include <rte_ethdev.h>
9 #include <rte_string_fns.h>
11 #include "rte_eth_softnic_internals.h"
14 softnic_link_init(struct pmd_internals *p)
16 TAILQ_INIT(&p->link_list);
22 softnic_link_free(struct pmd_internals *p)
25 struct softnic_link *link;
27 link = TAILQ_FIRST(&p->link_list);
31 TAILQ_REMOVE(&p->link_list, link, node);
37 softnic_link_find(struct pmd_internals *p,
40 struct softnic_link *link;
45 TAILQ_FOREACH(link, &p->link_list, node)
46 if (strcmp(link->name, name) == 0)
53 softnic_link_create(struct pmd_internals *p,
55 struct softnic_link_params *params)
57 struct rte_eth_dev_info port_info;
58 struct softnic_link *link;
61 /* Check input params */
63 softnic_link_find(p, name) ||
67 port_id = params->port_id;
68 if (params->dev_name) {
71 status = rte_eth_dev_get_port_by_name(params->dev_name,
77 if (!rte_eth_dev_is_valid_port(port_id))
81 rte_eth_dev_info_get(port_id, &port_info);
84 link = calloc(1, sizeof(struct softnic_link));
89 strlcpy(link->name, name, sizeof(link->name));
90 link->port_id = port_id;
91 link->n_rxq = port_info.nb_rx_queues;
92 link->n_txq = port_info.nb_tx_queues;
94 /* Node add to list */
95 TAILQ_INSERT_TAIL(&p->link_list, link, node);