DPDK  25.03.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 
54 #include <rte_common.h>
55 #include <rte_mbuf.h>
56 #include <rte_meter.h>
57 
59 #include "rte_red.h"
60 #include "rte_pie.h"
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
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 {
171 
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 
240 
243 
246 
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 
314 struct rte_sched_port;
315 
323 void
324 rte_sched_port_free(struct rte_sched_port *port);
325 
334 struct rte_sched_port *
337 
352 int
353 rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
354  uint32_t subport_id,
355  struct rte_sched_pipe_params *params,
356  uint32_t *pipe_profile_id);
357 
372 int
373 rte_sched_port_subport_profile_add(struct rte_sched_port *port,
374  struct rte_sched_subport_profile_params *profile,
375  uint32_t *subport_profile_id);
376 
395 int
396 rte_sched_subport_config(struct rte_sched_port *port,
397  uint32_t subport_id,
398  struct rte_sched_subport_params *params,
399  uint32_t subport_profile_id);
400 
415 int
416 rte_sched_pipe_config(struct rte_sched_port *port,
417  uint32_t subport_id,
418  uint32_t pipe_id,
419  int32_t pipe_profile);
420 
431 uint32_t
433  struct rte_sched_subport_params **subport_params);
434 
435 /*
436  * Statistics
437  */
438 
456 int
457 rte_sched_subport_read_stats(struct rte_sched_port *port,
458  uint32_t subport_id,
459  struct rte_sched_subport_stats *stats,
460  uint32_t *tc_ov);
461 
478 int
479 rte_sched_queue_read_stats(struct rte_sched_port *port,
480  uint32_t queue_id,
481  struct rte_sched_queue_stats *stats,
482  uint16_t *qlen);
483 
504 void
505 rte_sched_port_pkt_write(struct rte_sched_port *port,
506  struct rte_mbuf *pkt,
507  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
508  uint32_t queue, enum rte_color color);
509 
530 void
531 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
532  const struct rte_mbuf *pkt,
533  uint32_t *subport, uint32_t *pipe,
534  uint32_t *traffic_class, uint32_t *queue);
535 
536 enum rte_color
537 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
538 
557 int
558 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
559 
577 int
578 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
579 
594 int
595 rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable);
596 
597 #ifdef __cplusplus
598 }
599 #endif
600 
601 #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: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)
uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:239
#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
int rte_sched_port_subport_profile_add(struct rte_sched_port *port, struct rte_sched_subport_profile_params *profile, uint32_t *subport_profile_id)
uint64_t n_pkts_cman_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:248
uint64_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:236
#define __rte_dealloc(dealloc, argno)
Definition: rte_common.h:305
#define __rte_malloc
Definition: rte_common.h:294
uint64_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:242
uint32_t n_max_subport_profiles
Definition: rte_sched.h:300
rte_color
Definition: rte_meter.h:32
uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:245
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
struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) __rte_malloc __rte_dealloc(rte_sched_port_free
uint32_t n_pipes_per_subport
Definition: rte_sched.h:307
struct rte_sched_port 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)
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)