1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
6 #define __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
10 #include <sys/queue.h>
12 #include <rte_mempool.h>
15 #include <rte_ethdev.h>
16 #include <rte_sched.h>
17 #include <rte_port_in_action.h>
18 #include <rte_ethdev_driver.h>
19 #include <rte_tm_driver.h>
21 #include "rte_eth_softnic.h"
34 /** Traffic Management (TM) */
36 uint32_t n_queues; /**< Number of queues */
37 uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
44 struct softnic_mempool_params {
50 struct softnic_mempool {
51 TAILQ_ENTRY(softnic_mempool) node;
53 struct rte_mempool *m;
57 TAILQ_HEAD(softnic_mempool_list, softnic_mempool);
62 struct softnic_swq_params {
67 TAILQ_ENTRY(softnic_swq) node;
72 TAILQ_HEAD(softnic_swq_list, softnic_swq);
77 struct softnic_link_params {
79 uint16_t port_id; /**< Valid only when *dev_name* is NULL. */
83 TAILQ_ENTRY(softnic_link) node;
90 TAILQ_HEAD(softnic_link_list, softnic_link);
96 #ifndef TM_MAX_SUBPORTS
97 #define TM_MAX_SUBPORTS 8
100 #ifndef TM_MAX_PIPES_PER_SUBPORT
101 #define TM_MAX_PIPES_PER_SUBPORT 4096
105 struct rte_sched_port_params port_params;
107 struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
109 struct rte_sched_pipe_params
110 pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
111 uint32_t n_pipe_profiles;
112 uint32_t pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
117 TM_NODE_LEVEL_PORT = 0,
118 TM_NODE_LEVEL_SUBPORT,
125 /* TM Shaper Profile */
126 struct tm_shaper_profile {
127 TAILQ_ENTRY(tm_shaper_profile) node;
128 uint32_t shaper_profile_id;
130 struct rte_tm_shaper_params params;
133 TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
135 /* TM Shared Shaper */
136 struct tm_shared_shaper {
137 TAILQ_ENTRY(tm_shared_shaper) node;
138 uint32_t shared_shaper_id;
140 uint32_t shaper_profile_id;
143 TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
145 /* TM WRED Profile */
146 struct tm_wred_profile {
147 TAILQ_ENTRY(tm_wred_profile) node;
148 uint32_t wred_profile_id;
150 struct rte_tm_wred_params params;
153 TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
157 TAILQ_ENTRY(tm_node) node;
159 uint32_t parent_node_id;
163 struct tm_node *parent_node;
164 struct tm_shaper_profile *shaper_profile;
165 struct tm_wred_profile *wred_profile;
166 struct rte_tm_node_params params;
167 struct rte_tm_node_stats stats;
171 TAILQ_HEAD(tm_node_list, tm_node);
173 /* TM Hierarchy Specification */
174 struct tm_hierarchy {
175 struct tm_shaper_profile_list shaper_profiles;
176 struct tm_shared_shaper_list shared_shapers;
177 struct tm_wred_profile_list wred_profiles;
178 struct tm_node_list nodes;
180 uint32_t n_shaper_profiles;
181 uint32_t n_shared_shapers;
182 uint32_t n_wred_profiles;
185 uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
188 struct tm_internals {
189 /** Hierarchy specification
191 * -Hierarchy is unfrozen at init and when port is stopped.
192 * -Hierarchy is frozen on successful hierarchy commit.
193 * -Run-time hierarchy changes are not allowed, therefore it makes
194 * sense to keep the hierarchy frozen after the port is started.
196 struct tm_hierarchy h;
197 int hierarchy_frozen;
200 struct tm_params params;
201 struct rte_sched_port *sched;
204 struct softnic_tmgr_port {
205 TAILQ_ENTRY(softnic_tmgr_port) node;
206 char name[NAME_SIZE];
207 struct rte_sched_port *s;
210 TAILQ_HEAD(softnic_tmgr_port_list, softnic_tmgr_port);
216 TAILQ_ENTRY(softnic_tap) node;
217 char name[NAME_SIZE];
221 TAILQ_HEAD(softnic_tap_list, softnic_tap);
226 struct softnic_port_in_action_profile_params {
227 uint64_t action_mask;
228 struct rte_port_in_action_fltr_config fltr;
229 struct rte_port_in_action_lb_config lb;
232 struct softnic_port_in_action_profile {
233 TAILQ_ENTRY(softnic_port_in_action_profile) node;
234 char name[NAME_SIZE];
235 struct softnic_port_in_action_profile_params params;
236 struct rte_port_in_action_profile *ap;
239 TAILQ_HEAD(softnic_port_in_action_profile_list, softnic_port_in_action_profile);
244 struct pmd_internals {
246 struct pmd_params params;
249 struct tm_internals tm; /**< Traffic Management */
252 struct softnic_mempool_list mempool_list;
253 struct softnic_swq_list swq_list;
254 struct softnic_link_list link_list;
255 struct softnic_tmgr_port_list tmgr_port_list;
256 struct softnic_tap_list tap_list;
257 struct softnic_port_in_action_profile_list port_in_action_profile_list;
264 softnic_mempool_init(struct pmd_internals *p);
267 softnic_mempool_free(struct pmd_internals *p);
269 struct softnic_mempool *
270 softnic_mempool_find(struct pmd_internals *p,
273 struct softnic_mempool *
274 softnic_mempool_create(struct pmd_internals *p,
276 struct softnic_mempool_params *params);
282 softnic_swq_init(struct pmd_internals *p);
285 softnic_swq_free(struct pmd_internals *p);
288 softnic_swq_find(struct pmd_internals *p,
292 softnic_swq_create(struct pmd_internals *p,
294 struct softnic_swq_params *params);
300 softnic_link_init(struct pmd_internals *p);
303 softnic_link_free(struct pmd_internals *p);
305 struct softnic_link *
306 softnic_link_find(struct pmd_internals *p,
309 struct softnic_link *
310 softnic_link_create(struct pmd_internals *p,
312 struct softnic_link_params *params);
318 softnic_tmgr_init(struct pmd_internals *p);
321 softnic_tmgr_free(struct pmd_internals *p);
323 struct softnic_tmgr_port *
324 softnic_tmgr_port_find(struct pmd_internals *p,
327 struct softnic_tmgr_port *
328 softnic_tmgr_port_create(struct pmd_internals *p,
330 struct rte_sched_port *sched);
333 tm_init(struct pmd_internals *p);
336 tm_free(struct pmd_internals *p);
339 tm_start(struct pmd_internals *p);
342 tm_stop(struct pmd_internals *p);
345 tm_used(struct rte_eth_dev *dev)
347 struct pmd_internals *p = dev->data->dev_private;
349 return p->soft.tm.h.n_tm_nodes[TM_NODE_LEVEL_PORT];
352 extern const struct rte_tm_ops pmd_tm_ops;
358 softnic_tap_init(struct pmd_internals *p);
361 softnic_tap_free(struct pmd_internals *p);
364 softnic_tap_find(struct pmd_internals *p,
368 softnic_tap_create(struct pmd_internals *p,
375 softnic_port_in_action_profile_init(struct pmd_internals *p);
378 softnic_port_in_action_profile_free(struct pmd_internals *p);
380 struct softnic_port_in_action_profile *
381 softnic_port_in_action_profile_find(struct pmd_internals *p,
384 struct softnic_port_in_action_profile *
385 softnic_port_in_action_profile_create(struct pmd_internals *p,
387 struct softnic_port_in_action_profile_params *params);
389 #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */