DPDK  22.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 
59 #include <rte_compat.h>
60 #include <rte_mbuf.h>
61 #include <rte_meter.h>
62 
64 #include "rte_red.h"
65 #include "rte_pie.h"
66 
75 #define RTE_SCHED_QUEUES_PER_PIPE 16
76 
81 #define RTE_SCHED_BE_QUEUES_PER_PIPE 4
82 
87 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE \
88 (RTE_SCHED_QUEUES_PER_PIPE - RTE_SCHED_BE_QUEUES_PER_PIPE + 1)
89 
93 #define RTE_SCHED_TRAFFIC_CLASS_BE (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1)
94 
95 /*
96  * Ethernet framing overhead. Overhead fields per Ethernet frame:
97  * 1. Preamble: 7 bytes;
98  * 2. Start of Frame Delimiter (SFD): 1 byte;
99  * 3. Frame Check Sequence (FCS): 4 bytes;
100  * 4. Inter Frame Gap (IFG): 12 bytes.
101  *
102  * The FCS is considered overhead only if not included in the packet
103  * length (field pkt_len of struct rte_mbuf).
104  *
105  * @see struct rte_sched_port_params
106  */
107 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
108 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
109 #endif
110 
131 };
132 
133 /*
134  * Pipe configuration parameters. The period and credits_per_period
135  * parameters are measured in bytes, with one byte meaning the time
136  * duration associated with the transmission of one byte on the
137  * physical medium of the output port, with pipe or pipe traffic class
138  * rate (measured as percentage of output port rate) determined as
139  * credits_per_period divided by period. One credit represents one
140  * byte.
141  */
142 struct rte_sched_pipe_params {
144  uint64_t tb_rate;
145 
147  uint64_t tb_size;
148 
150  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
151 
153  uint64_t tc_period;
154 
156  uint8_t tc_ov_weight;
157 
159  uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
160 };
161 
162 /*
163  * Congestion Management configuration parameters.
164  */
165 struct rte_sched_cman_params {
167  enum rte_sched_cman_mode cman_mode;
168 
169  union {
171  struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
172 
174  struct rte_pie_params pie_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
175  };
176 };
177 
178 /*
179  * Subport configuration parameters. The period and credits_per_period
180  * parameters are measured in bytes, with one byte meaning the time
181  * duration associated with the transmission of one byte on the
182  * physical medium of the output port, with pipe or pipe traffic class
183  * rate (measured as percentage of output port rate) determined as
184  * credits_per_period divided by period. One credit represents one
185  * byte.
186  */
187 struct rte_sched_subport_params {
194  uint32_t n_pipes_per_subport_enabled;
195 
200  uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
201 
205  struct rte_sched_pipe_params *pipe_profiles;
206 
208  uint32_t n_pipe_profiles;
209 
211  uint32_t n_max_pipe_profiles;
212 
217  struct rte_sched_cman_params *cman_params;
218 };
219 
220 struct rte_sched_subport_profile_params {
222  uint64_t tb_rate;
223 
225  uint64_t tb_size;
226 
228  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
229 
231  uint64_t tc_period;
232 };
233 
238 
240  uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
241 
244 
246  uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
247 
249  uint64_t n_pkts_cman_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
250 };
251 
255  uint64_t n_pkts;
256 
258  uint64_t n_pkts_dropped;
259 
262 
264  uint64_t n_bytes;
265 
267  uint64_t n_bytes_dropped;
268 };
269 
273  const char *name;
274 
276  int socket;
277 
279  uint64_t rate;
280 
284  uint32_t mtu;
285 
287  uint32_t frame_overhead;
288 
291 
295  struct rte_sched_subport_profile_params *subport_profiles;
296 
299 
302 
309 };
310 
311 /*
312  * Configuration
313  *
314  ***/
315 
324 struct rte_sched_port *
326 
334 void
335 rte_sched_port_free(struct rte_sched_port *port);
336 
351 int
352 rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
353  uint32_t subport_id,
354  struct rte_sched_pipe_params *params,
355  uint32_t *pipe_profile_id);
356 
374 __rte_experimental
375 int
376 rte_sched_port_subport_profile_add(struct rte_sched_port *port,
377  struct rte_sched_subport_profile_params *profile,
378  uint32_t *subport_profile_id);
379 
398 int
399 rte_sched_subport_config(struct rte_sched_port *port,
400  uint32_t subport_id,
401  struct rte_sched_subport_params *params,
402  uint32_t subport_profile_id);
403 
418 int
419 rte_sched_pipe_config(struct rte_sched_port *port,
420  uint32_t subport_id,
421  uint32_t pipe_id,
422  int32_t pipe_profile);
423 
434 uint32_t
436  struct rte_sched_subport_params **subport_params);
437 /*
438  * Statistics
439  *
440  ***/
441 
459 int
460 rte_sched_subport_read_stats(struct rte_sched_port *port,
461  uint32_t subport_id,
462  struct rte_sched_subport_stats *stats,
463  uint32_t *tc_ov);
464 
481 int
482 rte_sched_queue_read_stats(struct rte_sched_port *port,
483  uint32_t queue_id,
484  struct rte_sched_queue_stats *stats,
485  uint16_t *qlen);
486 
507 void
508 rte_sched_port_pkt_write(struct rte_sched_port *port,
509  struct rte_mbuf *pkt,
510  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
511  uint32_t queue, enum rte_color color);
512 
533 void
534 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
535  const struct rte_mbuf *pkt,
536  uint32_t *subport, uint32_t *pipe,
537  uint32_t *traffic_class, uint32_t *queue);
538 
539 enum rte_color
540 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
541 
560 int
561 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
562 
580 int
581 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
582 
597 __rte_experimental
598 int
599 rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable);
600 
601 #ifdef __cplusplus
602 }
603 #endif
604 
605 #endif /* __INCLUDE_RTE_SCHED_H__ */
uint32_t n_subports_per_port
Definition: rte_sched.h:290
uint64_t n_pkts_cman_dropped
Definition: rte_sched.h:261
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:298
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:81
rte_sched_cman_mode
Definition: rte_sched.h:128
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:295
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:267
__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:301
rte_color
Definition: rte_meter.h:36
const char * name
Definition: rte_sched.h:273
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:258
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:87
uint32_t n_pipes_per_subport
Definition: rte_sched.h:308
uint32_t frame_overhead
Definition: rte_sched.h:287
int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile)