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>
14 #include <rte_ethdev.h>
15 #include <rte_sched.h>
16 #include <rte_ethdev_driver.h>
17 #include <rte_tm_driver.h>
19 #include "rte_eth_softnic.h"
32 /** Traffic Management (TM) */
34 uint32_t n_queues; /**< Number of queues */
35 uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
42 struct softnic_swq_params {
47 TAILQ_ENTRY(softnic_swq) node;
52 TAILQ_HEAD(softnic_swq_list, softnic_swq);
55 * Traffic Management (TM) Internals
58 #ifndef TM_MAX_SUBPORTS
59 #define TM_MAX_SUBPORTS 8
62 #ifndef TM_MAX_PIPES_PER_SUBPORT
63 #define TM_MAX_PIPES_PER_SUBPORT 4096
67 struct rte_sched_port_params port_params;
69 struct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];
71 struct rte_sched_pipe_params
72 pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
73 uint32_t n_pipe_profiles;
74 uint32_t pipe_to_profile[TM_MAX_SUBPORTS * TM_MAX_PIPES_PER_SUBPORT];
79 TM_NODE_LEVEL_PORT = 0,
80 TM_NODE_LEVEL_SUBPORT,
87 /* TM Shaper Profile */
88 struct tm_shaper_profile {
89 TAILQ_ENTRY(tm_shaper_profile) node;
90 uint32_t shaper_profile_id;
92 struct rte_tm_shaper_params params;
95 TAILQ_HEAD(tm_shaper_profile_list, tm_shaper_profile);
97 /* TM Shared Shaper */
98 struct tm_shared_shaper {
99 TAILQ_ENTRY(tm_shared_shaper) node;
100 uint32_t shared_shaper_id;
102 uint32_t shaper_profile_id;
105 TAILQ_HEAD(tm_shared_shaper_list, tm_shared_shaper);
107 /* TM WRED Profile */
108 struct tm_wred_profile {
109 TAILQ_ENTRY(tm_wred_profile) node;
110 uint32_t wred_profile_id;
112 struct rte_tm_wred_params params;
115 TAILQ_HEAD(tm_wred_profile_list, tm_wred_profile);
119 TAILQ_ENTRY(tm_node) node;
121 uint32_t parent_node_id;
125 struct tm_node *parent_node;
126 struct tm_shaper_profile *shaper_profile;
127 struct tm_wred_profile *wred_profile;
128 struct rte_tm_node_params params;
129 struct rte_tm_node_stats stats;
133 TAILQ_HEAD(tm_node_list, tm_node);
135 /* TM Hierarchy Specification */
136 struct tm_hierarchy {
137 struct tm_shaper_profile_list shaper_profiles;
138 struct tm_shared_shaper_list shared_shapers;
139 struct tm_wred_profile_list wred_profiles;
140 struct tm_node_list nodes;
142 uint32_t n_shaper_profiles;
143 uint32_t n_shared_shapers;
144 uint32_t n_wred_profiles;
147 uint32_t n_tm_nodes[TM_NODE_LEVEL_MAX];
150 struct tm_internals {
151 /** Hierarchy specification
153 * -Hierarchy is unfrozen at init and when port is stopped.
154 * -Hierarchy is frozen on successful hierarchy commit.
155 * -Run-time hierarchy changes are not allowed, therefore it makes
156 * sense to keep the hierarchy frozen after the port is started.
158 struct tm_hierarchy h;
159 int hierarchy_frozen;
162 struct tm_params params;
163 struct rte_sched_port *sched;
169 struct pmd_internals {
171 struct pmd_params params;
175 struct tm_internals tm; /**< Traffic Management */
178 struct softnic_swq_list swq_list;
185 softnic_swq_init(struct pmd_internals *p);
188 softnic_swq_free(struct pmd_internals *p);
191 softnic_swq_find(struct pmd_internals *p,
195 softnic_swq_create(struct pmd_internals *p,
197 struct softnic_swq_params *params);
200 * Traffic Management (TM) Operation
202 extern const struct rte_tm_ops pmd_tm_ops;
205 tm_init(struct pmd_internals *p, struct pmd_params *params, int numa_node);
208 tm_free(struct pmd_internals *p);
211 tm_start(struct pmd_internals *p);
214 tm_stop(struct pmd_internals *p);
217 tm_used(struct rte_eth_dev *dev __rte_unused)
222 #endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */