DPDK  23.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_compat.h>
59 #include <rte_mbuf.h>
60 #include <rte_meter.h>
61 
63 #include "rte_red.h"
64 #include "rte_pie.h"
65 
74 #define RTE_SCHED_QUEUES_PER_PIPE 16
75 
80 #define RTE_SCHED_BE_QUEUES_PER_PIPE 4
81 
86 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE \
87 (RTE_SCHED_QUEUES_PER_PIPE - RTE_SCHED_BE_QUEUES_PER_PIPE + 1)
88 
92 #define RTE_SCHED_TRAFFIC_CLASS_BE (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1)
93 
94 /*
95  * Ethernet framing overhead. Overhead fields per Ethernet frame:
96  * 1. Preamble: 7 bytes;
97  * 2. Start of Frame Delimiter (SFD): 1 byte;
98  * 3. Frame Check Sequence (FCS): 4 bytes;
99  * 4. Inter Frame Gap (IFG): 12 bytes.
100  *
101  * The FCS is considered overhead only if not included in the packet
102  * length (field pkt_len of struct rte_mbuf).
103  *
104  * @see struct rte_sched_port_params
105  */
106 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
107 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
108 #endif
109 
130 };
131 
132 /*
133  * Pipe configuration parameters. The period and credits_per_period
134  * parameters are measured in bytes, with one byte meaning the time
135  * duration associated with the transmission of one byte on the
136  * physical medium of the output port, with pipe or pipe traffic class
137  * rate (measured as percentage of output port rate) determined as
138  * credits_per_period divided by period. One credit represents one
139  * byte.
140  */
141 struct rte_sched_pipe_params {
143  uint64_t tb_rate;
144 
146  uint64_t tb_size;
147 
149  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
150 
152  uint64_t tc_period;
153 
155  uint8_t tc_ov_weight;
156 
158  uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
159 };
160 
161 /*
162  * Congestion Management configuration parameters.
163  */
164 struct rte_sched_cman_params {
166  enum rte_sched_cman_mode cman_mode;
167 
168  union {
170  struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
171 
173  struct rte_pie_params pie_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
174  };
175 };
176 
177 /*
178  * Subport configuration parameters. The period and credits_per_period
179  * parameters are measured in bytes, with one byte meaning the time
180  * duration associated with the transmission of one byte on the
181  * physical medium of the output port, with pipe or pipe traffic class
182  * rate (measured as percentage of output port rate) determined as
183  * credits_per_period divided by period. One credit represents one
184  * byte.
185  */
186 struct rte_sched_subport_params {
193  uint32_t n_pipes_per_subport_enabled;
194 
199  uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
200 
204  struct rte_sched_pipe_params *pipe_profiles;
205 
207  uint32_t n_pipe_profiles;
208 
210  uint32_t n_max_pipe_profiles;
211 
216  struct rte_sched_cman_params *cman_params;
217 };
218 
219 struct rte_sched_subport_profile_params {
221  uint64_t tb_rate;
222 
224  uint64_t tb_size;
225 
227  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
228 
230  uint64_t tc_period;
231 };
232 
237 
239  uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
240 
243 
245  uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
246 
248  uint64_t n_pkts_cman_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
249 };
250 
254  uint64_t n_pkts;
255 
257  uint64_t n_pkts_dropped;
258 
261 
263  uint64_t n_bytes;
264 
266  uint64_t n_bytes_dropped;
267 };
268 
272  const char *name;
273 
275  int socket;
276 
278  uint64_t rate;
279 
283  uint32_t mtu;
284 
286  uint32_t frame_overhead;
287 
290 
294  struct rte_sched_subport_profile_params *subport_profiles;
295 
298 
301 
308 };
309 
310 /*
311  * Configuration
312  */
313 
322 struct rte_sched_port *
324 
332 void
333 rte_sched_port_free(struct rte_sched_port *port);
334 
349 int
350 rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
351  uint32_t subport_id,
352  struct rte_sched_pipe_params *params,
353  uint32_t *pipe_profile_id);
354 
372 __rte_experimental
373 int
374 rte_sched_port_subport_profile_add(struct rte_sched_port *port,
375  struct rte_sched_subport_profile_params *profile,
376  uint32_t *subport_profile_id);
377 
396 int
397 rte_sched_subport_config(struct rte_sched_port *port,
398  uint32_t subport_id,
399  struct rte_sched_subport_params *params,
400  uint32_t subport_profile_id);
401 
416 int
417 rte_sched_pipe_config(struct rte_sched_port *port,
418  uint32_t subport_id,
419  uint32_t pipe_id,
420  int32_t pipe_profile);
421 
432 uint32_t
434  struct rte_sched_subport_params **subport_params);
435 
436 /*
437  * Statistics
438  */
439 
457 int
458 rte_sched_subport_read_stats(struct rte_sched_port *port,
459  uint32_t subport_id,
460  struct rte_sched_subport_stats *stats,
461  uint32_t *tc_ov);
462 
479 int
480 rte_sched_queue_read_stats(struct rte_sched_port *port,
481  uint32_t queue_id,
482  struct rte_sched_queue_stats *stats,
483  uint16_t *qlen);
484 
505 void
506 rte_sched_port_pkt_write(struct rte_sched_port *port,
507  struct rte_mbuf *pkt,
508  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
509  uint32_t queue, enum rte_color color);
510 
531 void
532 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
533  const struct rte_mbuf *pkt,
534  uint32_t *subport, uint32_t *pipe,
535  uint32_t *traffic_class, uint32_t *queue);
536 
537 enum rte_color
538 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
539 
558 int
559 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
560 
578 int
579 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
580 
595 __rte_experimental
596 int
597 rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable);
598 
599 #ifdef __cplusplus
600 }
601 #endif
602 
603 #endif /* __INCLUDE_RTE_SCHED_H__ */
uint32_t n_subports_per_port
Definition: rte_sched.h:289
uint64_t n_pkts_cman_dropped
Definition: rte_sched.h:260
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:297
int rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
__rte_experimental int rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable)
#define RTE_SCHED_BE_QUEUES_PER_PIPE
Definition: rte_sched.h:80
rte_sched_cman_mode
Definition: rte_sched.h:127
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:294
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:266
__rte_experimental int rte_sched_port_subport_profile_add(struct rte_sched_port *port, struct rte_sched_subport_profile_params *profile, uint32_t *subport_profile_id)
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)
uint32_t n_max_subport_profiles
Definition: rte_sched.h:300
rte_color
Definition: rte_meter.h:32
const char * name
Definition: rte_sched.h:272
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:257
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:86
uint32_t n_pipes_per_subport
Definition: rte_sched.h:307
uint32_t frame_overhead
Definition: rte_sched.h:286
int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile)