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
;
62 /* Check input params */
64 softnic_link_find(p
, name
) ||
68 port_id
= params
->port_id
;
69 if (params
->dev_name
) {
72 status
= rte_eth_dev_get_port_by_name(params
->dev_name
,
78 if (!rte_eth_dev_is_valid_port(port_id
))
82 ret
= rte_eth_dev_info_get(port_id
, &port_info
);
87 link
= calloc(1, sizeof(struct softnic_link
));
92 strlcpy(link
->name
, name
, sizeof(link
->name
));
93 link
->port_id
= port_id
;
94 link
->n_rxq
= port_info
.nb_rx_queues
;
95 link
->n_txq
= port_info
.nb_tx_queues
;
97 /* Node add to list */
98 TAILQ_INSERT_TAIL(&p
->link_list
, link
, node
);