DPDK  19.11.14
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 {
153  uint64_t tb_rate;
154 
156  uint64_t tb_size;
157 
159  uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
160 
162  uint64_t tc_period;
163 
170  uint32_t n_pipes_per_subport_enabled;
171 
176  uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
177 
181  struct rte_sched_pipe_params *pipe_profiles;
182 
184  uint32_t n_pipe_profiles;
185 
187  uint32_t n_max_pipe_profiles;
188 
189 #ifdef RTE_SCHED_RED
190 
191  struct rte_red_params red_params[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
192 #endif
193 };
194 
199 
201  uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
202 
205 
207  uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
208 
209 #ifdef RTE_SCHED_RED
210 
211  uint64_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
212 #endif
213 };
214 
218  uint64_t n_pkts;
219 
221  uint64_t n_pkts_dropped;
222 
223 #ifdef RTE_SCHED_RED
224 
225  uint64_t n_pkts_red_dropped;
226 #endif
227 
229  uint64_t n_bytes;
230 
232  uint64_t n_bytes_dropped;
233 };
234 
238  const char *name;
239 
241  int socket;
242 
244  uint64_t rate;
245 
249  uint32_t mtu;
250 
252  uint32_t frame_overhead;
253 
256 
263 };
264 
265 /*
266  * Configuration
267  *
268  ***/
269 
278 struct rte_sched_port *
280 
287 void
288 rte_sched_port_free(struct rte_sched_port *port);
289 
307 __rte_experimental
308 int
309 rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
310  uint32_t subport_id,
311  struct rte_sched_pipe_params *params,
312  uint32_t *pipe_profile_id);
313 
326 int
327 rte_sched_subport_config(struct rte_sched_port *port,
328  uint32_t subport_id,
329  struct rte_sched_subport_params *params);
330 
345 int
346 rte_sched_pipe_config(struct rte_sched_port *port,
347  uint32_t subport_id,
348  uint32_t pipe_id,
349  int32_t pipe_profile);
350 
361 uint32_t
363  struct rte_sched_subport_params **subport_params);
364 /*
365  * Statistics
366  *
367  ***/
368 
386 int
387 rte_sched_subport_read_stats(struct rte_sched_port *port,
388  uint32_t subport_id,
389  struct rte_sched_subport_stats *stats,
390  uint32_t *tc_ov);
391 
408 int
409 rte_sched_queue_read_stats(struct rte_sched_port *port,
410  uint32_t queue_id,
411  struct rte_sched_queue_stats *stats,
412  uint16_t *qlen);
413 
434 void
435 rte_sched_port_pkt_write(struct rte_sched_port *port,
436  struct rte_mbuf *pkt,
437  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
438  uint32_t queue, enum rte_color color);
439 
460 void
461 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
462  const struct rte_mbuf *pkt,
463  uint32_t *subport, uint32_t *pipe,
464  uint32_t *traffic_class, uint32_t *queue);
465 
466 enum rte_color
467 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
468 
487 int
488 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
489 
507 int
508 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
509 
510 #ifdef __cplusplus
511 }
512 #endif
513 
514 #endif /* __INCLUDE_RTE_SCHED_H__ */
uint32_t n_subports_per_port
Definition: rte_sched.h:255
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)
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)
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:232
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)
rte_color
Definition: rte_meter.h:36
const char * name
Definition: rte_sched.h:238
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:221
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:262
uint32_t frame_overhead
Definition: rte_sched.h:252
int rte_sched_pipe_config(struct rte_sched_port *port, uint32_t subport_id, uint32_t pipe_id, int32_t pipe_profile)
int rte_sched_subport_config(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_subport_params *params)