DPDK  21.05.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 <sys/types.h>
60 #include <rte_compat.h>
61 #include <rte_mbuf.h>
62 #include <rte_meter.h>
63 
65 #ifdef RTE_SCHED_RED
66 #include "rte_red.h"
67 #endif
68 
77 #define RTE_SCHED_QUEUES_PER_PIPE 16
78 
83 #define RTE_SCHED_BE_QUEUES_PER_PIPE 4
84 
89 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE \
90 (RTE_SCHED_QUEUES_PER_PIPE - RTE_SCHED_BE_QUEUES_PER_PIPE + 1)
91 
95 #define RTE_SCHED_TRAFFIC_CLASS_BE (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1)
96 
97 /*
98  * Ethernet framing overhead. Overhead fields per Ethernet frame:
99  * 1. Preamble: 7 bytes;
100  * 2. Start of Frame Delimiter (SFD): 1 byte;
101  * 3. Frame Check Sequence (FCS): 4 bytes;
102  * 4. Inter Frame Gap (IFG): 12 bytes.
103  *
104  * The FCS is considered overhead only if not included in the packet
105  * length (field pkt_len of struct rte_mbuf).
106  *
107  * @see struct rte_sched_port_params
108  */
109 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
110 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
111 #endif
112 
113 /*
114  * Pipe configuration parameters. The period and credits_per_period
115  * parameters are measured in bytes, with one byte meaning the time
116  * duration associated with the transmission of one byte on the
117  * physical medium of the output port, with pipe or pipe traffic class
118  * rate (measured as percentage of output port rate) determined as
119  * credits_per_period divided by period. One credit represents one
120  * byte.
121  */
122 struct rte_sched_pipe_params {
124  uint64_t tb_rate;
125 
127  uint64_t tb_size;
128 
130  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
131 
133  uint64_t tc_period;
134 
136  uint8_t tc_ov_weight;
137 
139  uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
140 };
141 
142 /*
143  * Subport configuration parameters. The period and credits_per_period
144  * parameters are measured in bytes, with one byte meaning the time
145  * duration associated with the transmission of one byte on the
146  * physical medium of the output port, with pipe or pipe traffic class
147  * rate (measured as percentage of output port rate) determined as
148  * credits_per_period divided by period. One credit represents one
149  * byte.
150  */
151 struct rte_sched_subport_params {
158  uint32_t n_pipes_per_subport_enabled;
159 
164  uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
165 
169  struct rte_sched_pipe_params *pipe_profiles;
170 
172  uint32_t n_pipe_profiles;
173 
175  uint32_t n_max_pipe_profiles;
176 
177 #ifdef RTE_SCHED_RED
178 
179  struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
180 #endif
181 };
182 
183 struct rte_sched_subport_profile_params {
185  uint64_t tb_rate;
186 
188  uint64_t tb_size;
189 
191  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
192 
194  uint64_t tc_period;
195 };
196 
201 
203  uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
204 
207 
209  uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
210 
211 #ifdef RTE_SCHED_RED
212 
213  uint64_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
214 #endif
215 };
216 
220  uint64_t n_pkts;
221 
223  uint64_t n_pkts_dropped;
224 
225 #ifdef RTE_SCHED_RED
226 
227  uint64_t n_pkts_red_dropped;
228 #endif
229 
231  uint64_t n_bytes;
232 
234  uint64_t n_bytes_dropped;
235 };
236 
240  const char *name;
241 
243  int socket;
244 
246  uint64_t rate;
247 
251  uint32_t mtu;
252 
254  uint32_t frame_overhead;
255 
258 
262  struct rte_sched_subport_profile_params *subport_profiles;
263 
266 
269 
276 };
277 
278 /*
279  * Configuration
280  *
281  ***/
282 
291 struct rte_sched_port *
293 
300 void
301 rte_sched_port_free(struct rte_sched_port *port);
302 
320 __rte_experimental
321 int
322 rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
323  uint32_t subport_id,
324  struct rte_sched_pipe_params *params,
325  uint32_t *pipe_profile_id);
326 
344 __rte_experimental
345 int
346 rte_sched_port_subport_profile_add(struct rte_sched_port *port,
347  struct rte_sched_subport_profile_params *profile,
348  uint32_t *subport_profile_id);
349 
368 int
369 rte_sched_subport_config(struct rte_sched_port *port,
370  uint32_t subport_id,
371  struct rte_sched_subport_params *params,
372  uint32_t subport_profile_id);
373 
388 int
389 rte_sched_pipe_config(struct rte_sched_port *port,
390  uint32_t subport_id,
391  uint32_t pipe_id,
392  int32_t pipe_profile);
393 
404 uint32_t
406  struct rte_sched_subport_params **subport_params);
407 /*
408  * Statistics
409  *
410  ***/
411 
429 int
430 rte_sched_subport_read_stats(struct rte_sched_port *port,
431  uint32_t subport_id,
432  struct rte_sched_subport_stats *stats,
433  uint32_t *tc_ov);
434 
451 int
452 rte_sched_queue_read_stats(struct rte_sched_port *port,
453  uint32_t queue_id,
454  struct rte_sched_queue_stats *stats,
455  uint16_t *qlen);
456 
477 void
478 rte_sched_port_pkt_write(struct rte_sched_port *port,
479  struct rte_mbuf *pkt,
480  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
481  uint32_t queue, enum rte_color color);
482 
503 void
504 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
505  const struct rte_mbuf *pkt,
506  uint32_t *subport, uint32_t *pipe,
507  uint32_t *traffic_class, uint32_t *queue);
508 
509 enum rte_color
510 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
511 
530 int
531 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
532 
550 int
551 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
552 
553 #ifdef __cplusplus
554 }
555 #endif
556 
557 #endif /* __INCLUDE_RTE_SCHED_H__ */
uint32_t n_subports_per_port
Definition: rte_sched.h:257
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:265
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:83
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:262
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:234
__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)
struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params)
__rte_experimental 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 n_max_subport_profiles
Definition: rte_sched.h:268
rte_color
Definition: rte_meter.h:36
const char * name
Definition: rte_sched.h:240
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:223
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:89
uint32_t n_pipes_per_subport
Definition: rte_sched.h:275
uint32_t frame_overhead
Definition: rte_sched.h:254
int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile)