DPDK  19.08.0-rc0
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 
72 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE 4
73 
75 #define RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS 4
76 
78 #define RTE_SCHED_QUEUES_PER_PIPE \
79  (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * \
80  RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
81 
85 #ifndef RTE_SCHED_PIPE_PROFILES_PER_PORT
86 #define RTE_SCHED_PIPE_PROFILES_PER_PORT 256
87 #endif
88 
89 /*
90  * Ethernet framing overhead. Overhead fields per Ethernet frame:
91  * 1. Preamble: 7 bytes;
92  * 2. Start of Frame Delimiter (SFD): 1 byte;
93  * 3. Frame Check Sequence (FCS): 4 bytes;
94  * 4. Inter Frame Gap (IFG): 12 bytes.
95  *
96  * The FCS is considered overhead only if not included in the packet
97  * length (field pkt_len of struct rte_mbuf).
98  */
99 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
100 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
101 #endif
102 
103 /*
104  * Subport configuration parameters. The period and credits_per_period
105  * parameters are measured in bytes, with one byte meaning the time
106  * duration associated with the transmission of one byte on the
107  * physical medium of the output port, with pipe or pipe traffic class
108  * rate (measured as percentage of output port rate) determined as
109  * credits_per_period divided by period. One credit represents one
110  * byte.
111  */
112 struct rte_sched_subport_params {
113  /* Subport token bucket */
114  uint32_t tb_rate;
115  uint32_t tb_size;
117  /* Subport traffic classes */
118  uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
120  uint32_t tc_period;
122 };
123 
126  /* Packets */
132  /* Bytes */
138 #ifdef RTE_SCHED_RED
139  uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
141 #endif
142 };
143 
144 /*
145  * Pipe configuration parameters. The period and credits_per_period
146  * parameters are measured in bytes, with one byte meaning the time
147  * duration associated with the transmission of one byte on the
148  * physical medium of the output port, with pipe or pipe traffic class
149  * rate (measured as percentage of output port rate) determined as
150  * credits_per_period divided by period. One credit represents one
151  * byte.
152  */
153 struct rte_sched_pipe_params {
154  /* Pipe token bucket */
155  uint32_t tb_rate;
156  uint32_t tb_size;
158  /* Pipe traffic classes */
159  uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
161  uint32_t tc_period;
163 #ifdef RTE_SCHED_SUBPORT_TC_OV
164  uint8_t tc_ov_weight;
165 #endif
166 
167  /* Pipe queues */
168  uint8_t wrr_weights[RTE_SCHED_QUEUES_PER_PIPE];
169 };
170 
173  /* Packets */
174  uint32_t n_pkts;
175  uint32_t n_pkts_dropped;
176 #ifdef RTE_SCHED_RED
177  uint32_t n_pkts_red_dropped;
178 #endif
179 
180  /* Bytes */
181  uint32_t n_bytes;
182  uint32_t n_bytes_dropped;
183 };
184 
187  const char *name;
188  int socket;
189  uint32_t rate;
191  uint32_t mtu;
194  uint32_t frame_overhead;
203  struct rte_sched_pipe_params *pipe_profiles;
206  uint32_t n_pipe_profiles;
207 #ifdef RTE_SCHED_RED
209 #endif
210 };
211 
212 /*
213  * Configuration
214  *
215  ***/
216 
225 struct rte_sched_port *
227 
234 void
235 rte_sched_port_free(struct rte_sched_port *port);
236 
252 int __rte_experimental
253 rte_sched_port_pipe_profile_add(struct rte_sched_port *port,
254  struct rte_sched_pipe_params *params,
255  uint32_t *pipe_profile_id);
256 
269 int
270 rte_sched_subport_config(struct rte_sched_port *port,
271  uint32_t subport_id,
272  struct rte_sched_subport_params *params);
273 
288 int
289 rte_sched_pipe_config(struct rte_sched_port *port,
290  uint32_t subport_id,
291  uint32_t pipe_id,
292  int32_t pipe_profile);
293 
302 uint32_t
304 
305 /*
306  * Statistics
307  *
308  ***/
309 
326 int
327 rte_sched_subport_read_stats(struct rte_sched_port *port,
328  uint32_t subport_id,
329  struct rte_sched_subport_stats *stats,
330  uint32_t *tc_ov);
331 
348 int
349 rte_sched_queue_read_stats(struct rte_sched_port *port,
350  uint32_t queue_id,
351  struct rte_sched_queue_stats *stats,
352  uint16_t *qlen);
353 
373 void
374 rte_sched_port_pkt_write(struct rte_sched_port *port,
375  struct rte_mbuf *pkt,
376  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
377  uint32_t queue, enum rte_color color);
378 
399 void
400 rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
401  const struct rte_mbuf *pkt,
402  uint32_t *subport, uint32_t *pipe,
403  uint32_t *traffic_class, uint32_t *queue);
404 
405 enum rte_color
406 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
407 
426 int
427 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
428 
446 int
447 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
448 
449 #ifdef __cplusplus
450 }
451 #endif
452 
453 #endif /* __INCLUDE_RTE_SCHED_H__ */
uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:135
uint32_t n_subports_per_port
Definition: rte_sched.h:196
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:127
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:175
uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:198
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:133
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)
int __rte_experimental 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_QUEUES_PER_PIPE
Definition: rte_sched.h:78
rte_color
Definition: rte_meter.h:36
const char * name
Definition: rte_sched.h:187
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)
struct rte_sched_pipe_params * pipe_profiles
Definition: rte_sched.h:203
#define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
Definition: rte_sched.h:72
uint32_t n_pipe_profiles
Definition: rte_sched.h:206
uint32_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:129
uint32_t n_pipes_per_subport
Definition: rte_sched.h:197
uint32_t frame_overhead
Definition: rte_sched.h:194
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:182
int rte_sched_subport_config(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_subport_params *params)