DPDK 22.11.7
rte_eth_softnic_internals.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
3 */
4
5#ifndef __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
6#define __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
7
8#include <stddef.h>
9#include <stdint.h>
10#include <sys/queue.h>
11
12#include <rte_mempool.h>
13#include <rte_mbuf.h>
14#include <rte_ring.h>
15#include <rte_ethdev.h>
16#include <rte_swx_pipeline.h>
17#include <rte_swx_ctl.h>
18
19#include <rte_ethdev_core.h>
20#include <ethdev_driver.h>
21
22#include "rte_eth_softnic.h"
23#include "conn.h"
24
25#define NAME_SIZE 64
26#define SOFTNIC_PATH_MAX 4096
27
32struct pmd_params {
33 char name[NAME_SIZE];
34 char firmware[SOFTNIC_PATH_MAX];
35 uint16_t conn_port;
36 uint32_t cpu_id;
37 int sc;
38};
39
44 uint32_t buffer_size;
45 uint32_t pool_size;
46 uint32_t cache_size;
47};
48
49struct softnic_mempool {
50 TAILQ_ENTRY(softnic_mempool) node;
51 char name[NAME_SIZE];
52 struct rte_mempool *m;
53 uint32_t buffer_size;
54};
55
56TAILQ_HEAD(softnic_mempool_list, softnic_mempool);
57
62 uint32_t size;
63};
64
65struct softnic_swq {
66 TAILQ_ENTRY(softnic_swq) node;
67 char name[NAME_SIZE];
68 struct rte_ring *r;
69};
70
71TAILQ_HEAD(softnic_swq_list, softnic_swq);
72
76struct pipeline {
77 TAILQ_ENTRY(pipeline) node;
78 char name[NAME_SIZE];
79
80 struct rte_swx_pipeline *p;
81 struct rte_swx_ctl_pipeline *ctl;
82
83 int enabled;
84 uint32_t thread_id;
85};
86
87TAILQ_HEAD(pipeline_list, pipeline);
88
92#ifndef THREAD_PIPELINES_MAX
93#define THREAD_PIPELINES_MAX 256
94#endif
95
96#ifndef THREAD_MSGQ_SIZE
97#define THREAD_MSGQ_SIZE 64
98#endif
99
100#ifndef THREAD_TIMER_PERIOD_MS
101#define THREAD_TIMER_PERIOD_MS 100
102#endif
103
104/* Pipeline instruction quanta: Needs to be big enough to do some meaningful
105 * work, but not too big to avoid starving any other pipelines mapped to the
106 * same thread. For a pipeline that executes 10 instructions per packet, a
107 * quanta of 1000 instructions equates to processing 100 packets.
108 */
109#ifndef PIPELINE_INSTR_QUANTA
110#define PIPELINE_INSTR_QUANTA 1000
111#endif
112
117 struct rte_ring *msgq_req;
118 struct rte_ring *msgq_rsp;
119
120 uint32_t service_id;
121};
122
127 struct rte_swx_pipeline *p[THREAD_PIPELINES_MAX];
128 uint32_t n_pipelines;
129
130 struct rte_ring *msgq_req;
131 struct rte_ring *msgq_rsp;
132 uint64_t timer_period; /* Measured in CPU cycles. */
133 uint64_t time_next;
134 uint64_t iter;
136
143
144 struct softnic_conn *conn;
145 struct softnic_mempool_list mempool_list;
146 struct softnic_swq_list swq_list;
147 struct pipeline_list pipeline_list;
148 struct softnic_thread thread[RTE_MAX_LCORE];
149 struct softnic_thread_data thread_data[RTE_MAX_LCORE];
150};
151
152static inline struct rte_eth_dev *
153ETHDEV(struct pmd_internals *softnic)
154{
155 uint16_t port_id;
156 int status;
157
158 if (softnic == NULL)
159 return NULL;
160
161 status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id);
162 if (status)
163 return NULL;
164
165 return &rte_eth_devices[port_id];
166}
167
171int
172softnic_mempool_init(struct pmd_internals *p);
173
174void
175softnic_mempool_free(struct pmd_internals *p);
176
177struct softnic_mempool *
178softnic_mempool_find(struct pmd_internals *p,
179 const char *name);
180
181struct softnic_mempool *
182softnic_mempool_create(struct pmd_internals *p,
183 const char *name,
184 struct softnic_mempool_params *params);
185
189int
190softnic_swq_init(struct pmd_internals *p);
191
192void
193softnic_swq_free(struct pmd_internals *p);
194
195void
196softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p);
197
198struct softnic_swq *
199softnic_swq_find(struct pmd_internals *p,
200 const char *name);
201
202struct softnic_swq *
203softnic_swq_create(struct pmd_internals *p,
204 const char *name,
205 struct softnic_swq_params *params);
206
210int
211softnic_pipeline_init(struct pmd_internals *p);
212
213void
214softnic_pipeline_free(struct pmd_internals *p);
215
216void
217softnic_pipeline_disable_all(struct pmd_internals *p);
218
219uint32_t
220softnic_pipeline_thread_count(struct pmd_internals *p, uint32_t thread_id);
221
222struct pipeline *
223softnic_pipeline_find(struct pmd_internals *p, const char *name);
224
225struct pipeline *
226softnic_pipeline_create(struct pmd_internals *p,
227 const char *name,
228 const char *lib_file_name,
229 const char *iospec_file_name,
230 int numa_node);
231
235int
236softnic_thread_init(struct pmd_internals *p);
237
238void
239softnic_thread_free(struct pmd_internals *p);
240
241int
242softnic_thread_pipeline_enable(struct pmd_internals *p,
243 uint32_t thread_id,
244 struct pipeline *pipeline);
245
246int
247softnic_thread_pipeline_disable(struct pmd_internals *p,
248 uint32_t thread_id,
249 struct pipeline *pipeline);
250
251void
252softnic_thread_pipeline_disable_all(struct pmd_internals *p);
253
257void
258softnic_cli_process(char *in,
259 char *out,
260 size_t out_size,
261 void *arg);
262
263int
264softnic_cli_script_process(struct pmd_internals *softnic,
265 const char *file_name,
266 size_t msg_in_len_max,
267 size_t msg_out_len_max);
268
269#endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */
#define __rte_cache_aligned
Definition: rte_common.h:440
int rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)
struct pmd_params params