DPDK  18.05.1
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 
371 void
373  uint32_t subport, uint32_t pipe, uint32_t traffic_class,
374  uint32_t queue, enum rte_meter_color color);
375 
394 void
396  uint32_t *subport, uint32_t *pipe,
397  uint32_t *traffic_class, uint32_t *queue);
398 
399 enum rte_meter_color
400 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
401 
420 int
421 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
422 
440 int
441 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 #endif /* __INCLUDE_RTE_SCHED_H__ */