DPDK  18.02.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_mbuf.h>
61 #include <rte_meter.h>
62 
64 #ifdef RTE_SCHED_RED
65 #include "rte_red.h"
66 #endif
67 
71 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE 4
72 
74 #define RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS 4
75 
77 #define RTE_SCHED_QUEUES_PER_PIPE \
78  (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * \
79  RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
80 
84 #ifndef RTE_SCHED_PIPE_PROFILES_PER_PORT
85 #define RTE_SCHED_PIPE_PROFILES_PER_PORT 256
86 #endif
87 
88 /*
89  * Ethernet framing overhead. Overhead fields per Ethernet frame:
90  * 1. Preamble: 7 bytes;
91  * 2. Start of Frame Delimiter (SFD): 1 byte;
92  * 3. Frame Check Sequence (FCS): 4 bytes;
93  * 4. Inter Frame Gap (IFG): 12 bytes.
94  *
95  * The FCS is considered overhead only if not included in the packet
96  * length (field pkt_len of struct rte_mbuf).
97  */
98 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
99 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
100 #endif
101 
102 /*
103  * Subport configuration parameters. The period and credits_per_period
104  * parameters are measured in bytes, with one byte meaning the time
105  * duration associated with the transmission of one byte on the
106  * physical medium of the output port, with pipe or pipe traffic class
107  * rate (measured as percentage of output port rate) determined as
108  * credits_per_period divided by period. One credit represents one
109  * byte.
110  */
111 struct rte_sched_subport_params {
112  /* Subport token bucket */
113  uint32_t tb_rate;
114  uint32_t tb_size;
116  /* Subport traffic classes */
117  uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
119  uint32_t tc_period;
121 };
122 
125  /* Packets */
131  /* Bytes */
137 #ifdef RTE_SCHED_RED
138  uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
140 #endif
141 };
142 
143 /*
144  * Pipe configuration parameters. The period and credits_per_period
145  * parameters are measured in bytes, with one byte meaning the time
146  * duration associated with the transmission of one byte on the
147  * physical medium of the output port, with pipe or pipe traffic class
148  * rate (measured as percentage of output port rate) determined as
149  * credits_per_period divided by period. One credit represents one
150  * byte.
151  */
152 struct rte_sched_pipe_params {
153  /* Pipe token bucket */
154  uint32_t tb_rate;
155  uint32_t tb_size;
157  /* Pipe traffic classes */
158  uint32_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
160  uint32_t tc_period;
162 #ifdef RTE_SCHED_SUBPORT_TC_OV
163  uint8_t tc_ov_weight;
164 #endif
165 
166  /* Pipe queues */
167  uint8_t wrr_weights[RTE_SCHED_QUEUES_PER_PIPE];
168 };
169 
172  /* Packets */
173  uint32_t n_pkts;
174  uint32_t n_pkts_dropped;
175 #ifdef RTE_SCHED_RED
176  uint32_t n_pkts_red_dropped;
177 #endif
178 
179  /* Bytes */
180  uint32_t n_bytes;
181  uint32_t n_bytes_dropped;
182 };
183 
186  const char *name;
187  int socket;
188  uint32_t rate;
190  uint32_t mtu;
193  uint32_t frame_overhead;
202  struct rte_sched_pipe_params *pipe_profiles;
205  uint32_t n_pipe_profiles;
206 #ifdef RTE_SCHED_RED
208 #endif
209 };
210 
211 /*
212  * Configuration
213  *
214  ***/
215 
224 struct rte_sched_port *
226 
233 void
234 rte_sched_port_free(struct rte_sched_port *port);
235 
248 int
249 rte_sched_subport_config(struct rte_sched_port *port,
250  uint32_t subport_id,
251  struct rte_sched_subport_params *params);
252 
267 int
268 rte_sched_pipe_config(struct rte_sched_port *port,
269  uint32_t subport_id,
270  uint32_t pipe_id,
271  int32_t pipe_profile);
272 
281 uint32_t
283 
284 /*
285  * Statistics
286  *
287  ***/
288 
305 int
306 rte_sched_subport_read_stats(struct rte_sched_port *port,
307  uint32_t subport_id,
308  struct rte_sched_subport_stats *stats,
309  uint32_t *tc_ov);
310 
327 int
328 rte_sched_queue_read_stats(struct rte_sched_port *port,
329  uint32_t queue_id,
330  struct rte_sched_queue_stats *stats,
331  uint16_t *qlen);
332 
350 void
352  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
353  uint32_t queue, enum rte_meter_color color);
354 
373 void
375  uint32_t *subport, uint32_t *pipe,
376  uint32_t *traffic_class, uint32_t *queue);
377 
378 enum rte_meter_color
379 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
380 
399 int
400 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
401 
419 int
420 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
421 
422 #ifdef __cplusplus
423 }
424 #endif
425 
426 #endif /* __INCLUDE_RTE_SCHED_H__ */