DPDK  24.07.0
rte_sched.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef __INCLUDE_RTE_SCHED_H__
6 #define __INCLUDE_RTE_SCHED_H__
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
58 #include <rte_mbuf.h>
59 #include <rte_meter.h>
60 
62 #include "rte_red.h"
63 #include "rte_pie.h"
64 
73 #define RTE_SCHED_QUEUES_PER_PIPE 16
74 
79 #define RTE_SCHED_BE_QUEUES_PER_PIPE 4
80 
85 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE \
86 (RTE_SCHED_QUEUES_PER_PIPE - RTE_SCHED_BE_QUEUES_PER_PIPE + 1)
87 
91 #define RTE_SCHED_TRAFFIC_CLASS_BE (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1)
92 
93 /*
94  * Ethernet framing overhead. Overhead fields per Ethernet frame:
95  * 1. Preamble: 7 bytes;
96  * 2. Start of Frame Delimiter (SFD): 1 byte;
97  * 3. Frame Check Sequence (FCS): 4 bytes;
98  * 4. Inter Frame Gap (IFG): 12 bytes.
99  *
100  * The FCS is considered overhead only if not included in the packet
101  * length (field pkt_len of struct rte_mbuf).
102  *
103  * @see struct rte_sched_port_params
104  */
105 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
106 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
107 #endif
108 
129 };
130 
131 /*
132  * Pipe configuration parameters. The period and credits_per_period
133  * parameters are measured in bytes, with one byte meaning the time
134  * duration associated with the transmission of one byte on the
135  * physical medium of the output port, with pipe or pipe traffic class
136  * rate (measured as percentage of output port rate) determined as
137  * credits_per_period divided by period. One credit represents one
138  * byte.
139  */
140 struct rte_sched_pipe_params {
142  uint64_t tb_rate;
143 
145  uint64_t tb_size;
146 
148  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
149 
151  uint64_t tc_period;
152 
154  uint8_t tc_ov_weight;
155 
157  uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
158 };
159 
160 /*
161  * Congestion Management configuration parameters.
162  */
163 struct rte_sched_cman_params {
165  enum rte_sched_cman_mode cman_mode;
166 
167  union {
169  struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
170 
172  struct rte_pie_params pie_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
173  };
174 };
175 
176 /*
177  * Subport configuration parameters. The period and credits_per_period
178  * parameters are measured in bytes, with one byte meaning the time
179  * duration associated with the transmission of one byte on the
180  * physical medium of the output port, with pipe or pipe traffic class
181  * rate (measured as percentage of output port rate) determined as
182  * credits_per_period divided by period. One credit represents one
183  * byte.
184  */
185 struct rte_sched_subport_params {
192  uint32_t n_pipes_per_subport_enabled;
193 
198  uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
199 
203  struct rte_sched_pipe_params *pipe_profiles;
204 
206  uint32_t n_pipe_profiles;
207 
209  uint32_t n_max_pipe_profiles;
210 
215  struct rte_sched_cman_params *cman_params;
216 };
217 
218 struct rte_sched_subport_profile_params {
220  uint64_t tb_rate;
221 
223  uint64_t tb_size;
224 
226  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
227 
229  uint64_t tc_period;
230 };
231 
236 
238  uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
239 
242 
244  uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
245 
247  uint64_t n_pkts_cman_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
248 };
249 
253  uint64_t n_pkts;
254 
256  uint64_t n_pkts_dropped;
257 
260 
262  uint64_t n_bytes;
263 
265  uint64_t n_bytes_dropped;
266 };
267 
271  const char *name;
272 
274  int socket;
275 
277  uint64_t rate;
278 
282  uint32_t mtu;
283 
285  uint32_t frame_overhead;
286 
289 
293  struct rte_sched_subport_profile_params *subport_profiles;
294 
297 
300 
307 };
308 
309 /*
310  * Configuration
311  */
312 
321 struct rte_sched_port *
323 
331 void
332 rte_sched_port_free(struct rte_sched_port *port);
333 
348 int
349 rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
350  uint32_t subport_id,
351  struct rte_sched_pipe_params *params,
352  uint32_t *pipe_profile_id);
353 
368 int
369 rte_sched_port_subport_profile_add(struct rte_sched_port *port,
370  struct rte_sched_subport_profile_params *profile,
371  uint32_t *subport_profile_id);
372 
391 int
392 rte_sched_subport_config(struct rte_sched_port *port,
393  uint32_t subport_id,
394  struct rte_sched_subport_params *params,
395  uint32_t subport_profile_id);
396 
411 int
412 rte_sched_pipe_config(struct rte_sched_port *port,
413  uint32_t subport_id,
414  uint32_t pipe_id,
415  int32_t pipe_profile);
416 
427 uint32_t
429  struct rte_sched_subport_params **subport_params);
430 
431 /*
432  * Statistics
433  */
434 
452 int
453 rte_sched_subport_read_stats(struct rte_sched_port *port,
454  uint32_t subport_id,
455  struct rte_sched_subport_stats *stats,
456  uint32_t *tc_ov);
457 
474 int
475 rte_sched_queue_read_stats(struct rte_sched_port *port,
476  uint32_t queue_id,
477  struct rte_sched_queue_stats *stats,
478  uint16_t *qlen);
479 
500 void
501 rte_sched_port_pkt_write(struct rte_sched_port *port,
502  struct rte_mbuf *pkt,
503  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
504  uint32_t queue, enum rte_color color);
505 
526 void
527 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
528  const struct rte_mbuf *pkt,
529  uint32_t *subport, uint32_t *pipe,
530  uint32_t *traffic_class, uint32_t *queue);
531 
532 enum rte_color
533 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
534 
553 int
554 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
555 
573 int
574 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
575 
590 int
591 rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable);
592 
593 #ifdef __cplusplus
594 }
595 #endif
596 
597 #endif /* __INCLUDE_RTE_SCHED_H__ */
int rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable)
uint32_t n_subports_per_port
Definition: rte_sched.h:288
uint64_t n_pkts_cman_dropped
Definition: rte_sched.h:259
int rte_sched_subport_config(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_subport_params *params, uint32_t subport_profile_id)
void rte_sched_port_pkt_write(struct rte_sched_port *port, struct rte_mbuf *pkt, uint32_t subport, uint32_t pipe, uint32_t traffic_class, uint32_t queue, enum rte_color color)
uint32_t n_subport_profiles
Definition: rte_sched.h:296
int rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
#define RTE_SCHED_BE_QUEUES_PER_PIPE
Definition: rte_sched.h:79
rte_sched_cman_mode
Definition: rte_sched.h:126
int rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
void rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port, const struct rte_mbuf *pkt, uint32_t *subport, uint32_t *pipe, uint32_t *traffic_class, uint32_t *queue)
struct rte_sched_subport_profile_params * subport_profiles
Definition: rte_sched.h:293
uint32_t rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params, struct rte_sched_subport_params **subport_params)
uint64_t n_bytes_dropped
Definition: rte_sched.h:265
int rte_sched_subport_pipe_profile_add(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id)
struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params)
int rte_sched_port_subport_profile_add(struct rte_sched_port *port, struct rte_sched_subport_profile_params *profile, uint32_t *subport_profile_id)
uint32_t n_max_subport_profiles
Definition: rte_sched.h:299
rte_color
Definition: rte_meter.h:32
const char * name
Definition: rte_sched.h:271
int rte_sched_subport_read_stats(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_subport_stats *stats, uint32_t *tc_ov)
uint64_t n_pkts_dropped
Definition: rte_sched.h:256
void rte_sched_port_free(struct rte_sched_port *port)
int rte_sched_queue_read_stats(struct rte_sched_port *port, uint32_t queue_id, struct rte_sched_queue_stats *stats, uint16_t *qlen)
#define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
Definition: rte_sched.h:85
uint32_t n_pipes_per_subport
Definition: rte_sched.h:306
uint32_t frame_overhead
Definition: rte_sched.h:285
int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile)