DPDK  21.11.8
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 <sys/types.h>
60 #include <rte_compat.h>
61 #include <rte_mbuf.h>
62 #include <rte_meter.h>
63 
65 #include "rte_red.h"
66 #include "rte_pie.h"
67 
76 #define RTE_SCHED_QUEUES_PER_PIPE 16
77 
82 #define RTE_SCHED_BE_QUEUES_PER_PIPE 4
83 
88 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE \
89 (RTE_SCHED_QUEUES_PER_PIPE - RTE_SCHED_BE_QUEUES_PER_PIPE + 1)
90 
94 #define RTE_SCHED_TRAFFIC_CLASS_BE (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1)
95 
96 /*
97  * Ethernet framing overhead. Overhead fields per Ethernet frame:
98  * 1. Preamble: 7 bytes;
99  * 2. Start of Frame Delimiter (SFD): 1 byte;
100  * 3. Frame Check Sequence (FCS): 4 bytes;
101  * 4. Inter Frame Gap (IFG): 12 bytes.
102  *
103  * The FCS is considered overhead only if not included in the packet
104  * length (field pkt_len of struct rte_mbuf).
105  *
106  * @see struct rte_sched_port_params
107  */
108 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
109 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
110 #endif
111 
132 };
133 
134 /*
135  * Pipe configuration parameters. The period and credits_per_period
136  * parameters are measured in bytes, with one byte meaning the time
137  * duration associated with the transmission of one byte on the
138  * physical medium of the output port, with pipe or pipe traffic class
139  * rate (measured as percentage of output port rate) determined as
140  * credits_per_period divided by period. One credit represents one
141  * byte.
142  */
143 struct rte_sched_pipe_params {
145  uint64_t tb_rate;
146 
148  uint64_t tb_size;
149 
151  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
152 
154  uint64_t tc_period;
155 
157  uint8_t tc_ov_weight;
158 
160  uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
161 };
162 
163 /*
164  * Congestion Management configuration parameters.
165  */
166 struct rte_sched_cman_params {
168  enum rte_sched_cman_mode cman_mode;
169 
170  union {
172  struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
173 
175  struct rte_pie_params pie_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
176  };
177 };
178 
179 /*
180  * Subport configuration parameters. The period and credits_per_period
181  * parameters are measured in bytes, with one byte meaning the time
182  * duration associated with the transmission of one byte on the
183  * physical medium of the output port, with pipe or pipe traffic class
184  * rate (measured as percentage of output port rate) determined as
185  * credits_per_period divided by period. One credit represents one
186  * byte.
187  */
188 struct rte_sched_subport_params {
195  uint32_t n_pipes_per_subport_enabled;
196 
201  uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
202 
206  struct rte_sched_pipe_params *pipe_profiles;
207 
209  uint32_t n_pipe_profiles;
210 
212  uint32_t n_max_pipe_profiles;
213 
218  struct rte_sched_cman_params *cman_params;
219 };
220 
221 struct rte_sched_subport_profile_params {
223  uint64_t tb_rate;
224 
226  uint64_t tb_size;
227 
229  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
230 
232  uint64_t tc_period;
233 };
234 
239 
241  uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
242 
245 
247  uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
248 
250  uint64_t n_pkts_cman_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
251 };
252 
256  uint64_t n_pkts;
257 
259  uint64_t n_pkts_dropped;
260 
263 
265  uint64_t n_bytes;
266 
268  uint64_t n_bytes_dropped;
269 };
270 
274  const char *name;
275 
277  int socket;
278 
280  uint64_t rate;
281 
285  uint32_t mtu;
286 
288  uint32_t frame_overhead;
289 
292 
296  struct rte_sched_subport_profile_params *subport_profiles;
297 
300 
303 
310 };
311 
312 /*
313  * Configuration
314  *
315  ***/
316 
325 struct rte_sched_port *
327 
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 
583 #ifdef __cplusplus
584 }
585 #endif
586 
587 #endif /* __INCLUDE_RTE_SCHED_H__ */
uint32_t n_subports_per_port
Definition: rte_sched.h:291
uint64_t n_pkts_cman_dropped
Definition: rte_sched.h:262
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:299
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:82
rte_sched_cman_mode
Definition: rte_sched.h:129
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:296
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:268
__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:302
rte_color
Definition: rte_meter.h:36
const char * name
Definition: rte_sched.h:274
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:259
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:88
uint32_t n_pipes_per_subport
Definition: rte_sched.h:309
uint32_t frame_overhead
Definition: rte_sched.h:288
int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile)