DPDK  2.1.0
rte_sched.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of Intel Corporation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __INCLUDE_RTE_SCHED_H__
35 #define __INCLUDE_RTE_SCHED_H__
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
79 #include <sys/types.h>
80 #include <rte_mbuf.h>
81 #include <rte_meter.h>
82 
84 #ifdef RTE_SCHED_RED
85 #include "rte_red.h"
86 #endif
87 
89 #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE 4
90 
92 #define RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS 4
93 
95 #define RTE_SCHED_QUEUES_PER_PIPE \
96  (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE * \
97  RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
98 
100 #ifndef RTE_SCHED_PIPE_PROFILES_PER_PORT
101 #define RTE_SCHED_PIPE_PROFILES_PER_PORT 256
102 #endif
103 
111 #ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
112 #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
113 #endif
114 
121  /* Subport token bucket */
122  uint32_t tb_rate;
123  uint32_t tb_size;
125  /* Subport traffic classes */
127  uint32_t tc_period;
128 };
129 
132  /* Packets */
138  /* Bytes */
143 };
144 
151  /* Pipe token bucket */
152  uint32_t tb_rate;
153  uint32_t tb_size;
155  /* Pipe traffic classes */
157  uint32_t tc_period;
158 #ifdef RTE_SCHED_SUBPORT_TC_OV
159  uint8_t tc_ov_weight;
160 #endif
161 
162  /* Pipe queues */
164 };
165 
168  /* Packets */
169  uint32_t n_pkts;
170  uint32_t n_pkts_dropped;
172  /* Bytes */
173  uint32_t n_bytes;
174  uint32_t n_bytes_dropped;
175 };
176 
179  const char *name;
180  int socket;
181  uint32_t rate;
182  uint32_t mtu;
183  uint32_t frame_overhead;
192  uint32_t n_pipe_profiles;
193 #ifdef RTE_SCHED_RED
195 #endif
196 };
197 
198 /*
199  * Path through scheduler hierarchy
200  *
201  * Note: direct access to internal bitfields is deprecated to allow for future expansion.
202  * Use rte_sched_port_pkt_read/write API instead
203  */
204 struct rte_sched_port_hierarchy {
205  uint32_t queue:2;
206  uint32_t traffic_class:2;
207  uint32_t pipe:20;
208  uint32_t subport:6;
209  uint32_t color:2;
210 } __attribute__ ((deprecated));
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 
249 int
250 rte_sched_subport_config(struct rte_sched_port *port,
251  uint32_t subport_id,
252  struct rte_sched_subport_params *params);
253 
268 int
269 rte_sched_pipe_config(struct rte_sched_port *port,
270  uint32_t subport_id,
271  uint32_t pipe_id,
272  int32_t pipe_profile);
273 
282 uint32_t
284 
285 /*
286  * Statistics
287  *
288  ***/
289 
306 int
307 rte_sched_subport_read_stats(struct rte_sched_port *port,
308  uint32_t subport_id,
309  struct rte_sched_subport_stats *stats,
310  uint32_t *tc_ov);
311 
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 
372 void
374  uint32_t *subport, uint32_t *pipe,
375  uint32_t *traffic_class, uint32_t *queue);
376 
377 enum rte_meter_color
378 rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
379 
397 int
398 rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
399 
415 int
416 rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
417 
418 #ifdef __cplusplus
419 }
420 #endif
421 
422 #endif /* __INCLUDE_RTE_SCHED_H__ */