DPDK  19.08.2
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  * Subport 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_subport_params {
124  uint32_t tb_rate;
125 
127  uint32_t tb_size;
128 
130  uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
131 
133  uint32_t tc_period;
134 };
135 
140 
143 
146 
149 
150 #ifdef RTE_SCHED_RED
151 
152  uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
153 #endif
154 };
155 
156 /*
157  * Pipe configuration parameters. The period and credits_per_period
158  * parameters are measured in bytes, with one byte meaning the time
159  * duration associated with the transmission of one byte on the
160  * physical medium of the output port, with pipe or pipe traffic class
161  * rate (measured as percentage of output port rate) determined as
162  * credits_per_period divided by period. One credit represents one
163  * byte.
164  */
165 struct rte_sched_pipe_params {
167  uint32_t tb_rate;
168 
170  uint32_t tb_size;
171 
173  uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
174 
176  uint32_t tc_period;
177 
179  uint8_t tc_ov_weight;
180 
182  uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
183 };
184 
188  uint32_t n_pkts;
189 
191  uint32_t n_pkts_dropped;
192 
193 #ifdef RTE_SCHED_RED
194 
195  uint32_t n_pkts_red_dropped;
196 #endif
197 
199  uint32_t n_bytes;
200 
202  uint32_t n_bytes_dropped;
203 };
204 
208  const char *name;
209 
211  int socket;
212 
214  uint32_t rate;
215 
219  uint32_t mtu;
220 
222  uint32_t frame_overhead;
223 
226 
229 
235 
239  struct rte_sched_pipe_params *pipe_profiles;
240 
242  uint32_t n_pipe_profiles;
243 
246 
247 #ifdef RTE_SCHED_RED
248 
250 #endif
251 };
252 
253 /*
254  * Configuration
255  *
256  ***/
257 
266 struct rte_sched_port *
268 
275 void
276 rte_sched_port_free(struct rte_sched_port *port);
277 
293 __rte_experimental
294 int
295 rte_sched_port_pipe_profile_add(struct rte_sched_port *port,
296  struct rte_sched_pipe_params *params,
297  uint32_t *pipe_profile_id);
298 
311 int
312 rte_sched_subport_config(struct rte_sched_port *port,
313  uint32_t subport_id,
314  struct rte_sched_subport_params *params);
315 
330 int
331 rte_sched_pipe_config(struct rte_sched_port *port,
332  uint32_t subport_id,
333  uint32_t pipe_id,
334  int32_t pipe_profile);
335 
344 uint32_t
346 
347 /*
348  * Statistics
349  *
350  ***/
351 
369 int
370 rte_sched_subport_read_stats(struct rte_sched_port *port,
371  uint32_t subport_id,
372  struct rte_sched_subport_stats *stats,
373  uint32_t *tc_ov);
374 
391 int
392 rte_sched_queue_read_stats(struct rte_sched_port *port,
393  uint32_t queue_id,
394  struct rte_sched_queue_stats *stats,
395  uint16_t *qlen);
396 
417 void
418 rte_sched_port_pkt_write(struct rte_sched_port *port,
419  struct rte_mbuf *pkt,
420  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
421  uint32_t queue, enum rte_color color);
422 
443 void
444 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
445  const struct rte_mbuf *pkt,
446  uint32_t *subport, uint32_t *pipe,
447  uint32_t *traffic_class, uint32_t *queue);
448 
449 enum rte_color
450 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
451 
470 int
471 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
472 
490 int
491 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
492 
493 #ifdef __cplusplus
494 }
495 #endif
496 
497 #endif /* __INCLUDE_RTE_SCHED_H__ */
uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:148
uint32_t n_subports_per_port
Definition: rte_sched.h:225
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_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:139
int rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
uint32_t n_pkts_dropped
Definition: rte_sched.h:191
#define RTE_SCHED_BE_QUEUES_PER_PIPE
Definition: rte_sched.h:83
uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:234
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)
uint32_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:145
struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params)
uint32_t rte_sched_port_get_memory_footprint(struct rte_sched_port_params *params)
rte_color
Definition: rte_meter.h:36
const char * name
Definition: rte_sched.h:208
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)
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)
uint32_t n_max_pipe_profiles
Definition: rte_sched.h:245
struct rte_sched_pipe_params * pipe_profiles
Definition: rte_sched.h:239
__rte_experimental int rte_sched_port_pipe_profile_add(struct rte_sched_port *port, struct rte_sched_pipe_params *params, uint32_t *pipe_profile_id)
#define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
Definition: rte_sched.h:89
uint32_t n_pipe_profiles
Definition: rte_sched.h:242
uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:142
uint32_t n_pipes_per_subport
Definition: rte_sched.h:228
uint32_t frame_overhead
Definition: rte_sched.h:222
int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile)
uint32_t n_bytes_dropped
Definition: rte_sched.h:202
int rte_sched_subport_config(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_subport_params *params)