1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
7 #include <rte_cycles.h>
11 #include "rte_eth_softnic_internals.h"
14 * Master thread: data plane thread init
17 softnic_thread_free(struct pmd_internals *softnic)
21 RTE_LCORE_FOREACH_SLAVE(i) {
22 struct softnic_thread *t = &softnic->thread[i];
26 rte_ring_free(t->msgq_req);
29 rte_ring_free(t->msgq_rsp);
34 softnic_thread_init(struct pmd_internals *softnic)
38 RTE_LCORE_FOREACH_SLAVE(i) {
39 char ring_name[NAME_MAX];
40 struct rte_ring *msgq_req, *msgq_rsp;
41 struct softnic_thread *t = &softnic->thread[i];
42 struct softnic_thread_data *t_data = &softnic->thread_data[i];
43 uint32_t cpu_id = rte_lcore_to_socket_id(i);
46 snprintf(ring_name, sizeof(ring_name), "%s-TH%u-REQ",
50 msgq_req = rte_ring_create(ring_name,
53 RING_F_SP_ENQ | RING_F_SC_DEQ);
55 if (msgq_req == NULL) {
56 softnic_thread_free(softnic);
60 snprintf(ring_name, sizeof(ring_name), "%s-TH%u-RSP",
64 msgq_rsp = rte_ring_create(ring_name,
67 RING_F_SP_ENQ | RING_F_SC_DEQ);
69 if (msgq_rsp == NULL) {
70 softnic_thread_free(softnic);
74 /* Master thread records */
75 t->msgq_req = msgq_req;
76 t->msgq_rsp = msgq_rsp;
79 /* Data plane thread records */
80 t_data->n_pipelines = 0;
81 t_data->msgq_req = msgq_req;
82 t_data->msgq_rsp = msgq_rsp;
83 t_data->timer_period =
84 (rte_get_tsc_hz() * THREAD_TIMER_PERIOD_MS) / 1000;
85 t_data->time_next = rte_get_tsc_cycles() + t_data->timer_period;
86 t_data->time_next_min = t_data->time_next;