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_ethdev_driver.h>
18 #include <rte_tm_driver.h>
20 #include "rte_eth_softnic.h"
33 /** Traffic Management (TM) */
35 uint32_t n_queues; /**< Number of queues */
36 uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
43 struct softnic_mempool_params {
49 struct softnic_mempool {
50 TAILQ_ENTRY(softnic_mempool) node;
52 struct rte_mempool *m;
56 TAILQ_HEAD(softnic_mempool_list, softnic_mempool);
61 struct softnic_swq_params {
66 TAILQ_ENTRY(softnic_swq) node;
71 TAILQ_HEAD(softnic_swq_list, softnic_swq);
76 struct softnic_link_params {
78 uint16_t port_id; /**< Valid only when *dev_name* is NULL. */
82 TAILQ_ENTRY(softnic_link) node;
89 TAILQ_HEAD(softnic_link_list, softnic_link);
92 * Traffic Management (TM) Internals
95 #ifndef TM_MAX_SUBPORTS
96 #define TM_MAX_SUBPORTS 8
99 #ifndef TM_MAX_PIPES_PER_SUBPORT
100 #define TM_MAX_PIPES_PER_SUBPORT 4096
104 struct rte_sched_port_params port_params;
106 struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
108 struct rte_sched_pipe_params
109 pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
110 uint32_t n_pipe_profiles;
111 uint32_t pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
116 TM_NODE_LEVEL_PORT = 0,
117 TM_NODE_LEVEL_SUBPORT,
124 /* TM Shaper Profile */
125 struct tm_shaper_profile {
126 TAILQ_ENTRY(tm_shaper_profile) node;
127 uint32_t shaper_profile_id;
129 struct rte_tm_shaper_params params;
132 TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
134 /* TM Shared Shaper */
135 struct tm_shared_shaper {
136 TAILQ_ENTRY(tm_shared_shaper) node;
137 uint32_t shared_shaper_id;
139 uint32_t shaper_profile_id;
142 TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
144 /* TM WRED Profile */
145 struct tm_wred_profile {
146 TAILQ_ENTRY(tm_wred_profile) node;
147 uint32_t wred_profile_id;
149 struct rte_tm_wred_params params;
152 TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
156 TAILQ_ENTRY(tm_node) node;
158 uint32_t parent_node_id;
162 struct tm_node *parent_node;
163 struct tm_shaper_profile *shaper_profile;
164 struct tm_wred_profile *wred_profile;
165 struct rte_tm_node_params params;
166 struct rte_tm_node_stats stats;
170 TAILQ_HEAD(tm_node_list, tm_node);
172 /* TM Hierarchy Specification */
173 struct tm_hierarchy {
174 struct tm_shaper_profile_list shaper_profiles;
175 struct tm_shared_shaper_list shared_shapers;
176 struct tm_wred_profile_list wred_profiles;
177 struct tm_node_list nodes;
179 uint32_t n_shaper_profiles;
180 uint32_t n_shared_shapers;
181 uint32_t n_wred_profiles;
184 uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
187 struct tm_internals {
188 /** Hierarchy specification
190 * -Hierarchy is unfrozen at init and when port is stopped.
191 * -Hierarchy is frozen on successful hierarchy commit.
192 * -Run-time hierarchy changes are not allowed, therefore it makes
193 * sense to keep the hierarchy frozen after the port is started.
195 struct tm_hierarchy h;
196 int hierarchy_frozen;
199 struct tm_params params;
200 struct rte_sched_port *sched;
206 struct pmd_internals {
208 struct pmd_params params;
212 struct tm_internals tm; /**< Traffic Management */
215 struct softnic_mempool_list mempool_list;
216 struct softnic_swq_list swq_list;
217 struct softnic_link_list link_list;
224 softnic_mempool_init(struct pmd_internals *p);
227 softnic_mempool_free(struct pmd_internals *p);
229 struct softnic_mempool *
230 softnic_mempool_find(struct pmd_internals *p,
233 struct softnic_mempool *
234 softnic_mempool_create(struct pmd_internals *p,
236 struct softnic_mempool_params *params);
242 softnic_swq_init(struct pmd_internals *p);
245 softnic_swq_free(struct pmd_internals *p);
248 softnic_swq_find(struct pmd_internals *p,
252 softnic_swq_create(struct pmd_internals *p,
254 struct softnic_swq_params *params);
260 softnic_link_init(struct pmd_internals *p);
263 softnic_link_free(struct pmd_internals *p);
265 struct softnic_link *
266 softnic_link_find(struct pmd_internals *p,
269 struct softnic_link *
270 softnic_link_create(struct pmd_internals *p,
272 struct softnic_link_params *params);
275 * Traffic Management (TM) Operation
277 extern const struct rte_tm_ops pmd_tm_ops;
280 tm_init(struct pmd_internals *p, struct pmd_params *params, int numa_node);
283 tm_free(struct pmd_internals *p);
286 tm_start(struct pmd_internals *p);
289 tm_stop(struct pmd_internals *p);
292 tm_used(struct rte_eth_dev *dev __rte_unused)
297 #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */