DPDK 25.03.0-rc1
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
54#include <rte_common.h>
55#include <rte_mbuf.h>
56#include <rte_meter.h>
57
59#include "rte_red.h"
60#include "rte_pie.h"
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
74#define RTE_SCHED_QUEUES_PER_PIPE 16
75
80#define RTE_SCHED_BE_QUEUES_PER_PIPE 4
81
86#define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE \
87(RTE_SCHED_QUEUES_PER_PIPE - RTE_SCHED_BE_QUEUES_PER_PIPE + 1)
88
92#define RTE_SCHED_TRAFFIC_CLASS_BE (RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1)
93
94/*
95 * Ethernet framing overhead. Overhead fields per Ethernet frame:
96 * 1. Preamble: 7 bytes;
97 * 2. Start of Frame Delimiter (SFD): 1 byte;
98 * 3. Frame Check Sequence (FCS): 4 bytes;
99 * 4. Inter Frame Gap (IFG): 12 bytes.
100 *
101 * The FCS is considered overhead only if not included in the packet
102 * length (field pkt_len of struct rte_mbuf).
103 *
104 * @see struct rte_sched_port_params
105 */
106#ifndef RTE_SCHED_FRAME_OVERHEAD_DEFAULT
107#define RTE_SCHED_FRAME_OVERHEAD_DEFAULT 24
108#endif
109
130};
131
132/*
133 * Pipe configuration parameters. The period and credits_per_period
134 * parameters are measured in bytes, with one byte meaning the time
135 * duration associated with the transmission of one byte on the
136 * physical medium of the output port, with pipe or pipe traffic class
137 * rate (measured as percentage of output port rate) determined as
138 * credits_per_period divided by period. One credit represents one
139 * byte.
140 */
141struct rte_sched_pipe_params {
143 uint64_t tb_rate;
144
146 uint64_t tb_size;
147
149 uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
150
152 uint64_t tc_period;
153
155 uint8_t tc_ov_weight;
156
158 uint8_t wrr_weights[RTE_SCHED_BE_QUEUES_PER_PIPE];
159};
160
161/*
162 * Congestion Management configuration parameters.
163 */
164struct rte_sched_cman_params {
166 enum rte_sched_cman_mode cman_mode;
167
168 union {
171
174 };
175};
176
177/*
178 * Subport configuration parameters. The period and credits_per_period
179 * parameters are measured in bytes, with one byte meaning the time
180 * duration associated with the transmission of one byte on the
181 * physical medium of the output port, with pipe or pipe traffic class
182 * rate (measured as percentage of output port rate) determined as
183 * credits_per_period divided by period. One credit represents one
184 * byte.
185 */
186struct rte_sched_subport_params {
193 uint32_t n_pipes_per_subport_enabled;
194
200
204 struct rte_sched_pipe_params *pipe_profiles;
205
207 uint32_t n_pipe_profiles;
208
210 uint32_t n_max_pipe_profiles;
211
216 struct rte_sched_cman_params *cman_params;
217};
218
219struct rte_sched_subport_profile_params {
221 uint64_t tb_rate;
222
224 uint64_t tb_size;
225
227 uint64_t tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
228
230 uint64_t tc_period;
231};
232
237
240
243
246
249};
250
254 uint64_t n_pkts;
255
258
261
263 uint64_t n_bytes;
264
267};
268
272 const char *name;
273
276
278 uint64_t rate;
279
283 uint32_t mtu;
284
287
290
294 struct rte_sched_subport_profile_params *subport_profiles;
295
298
301
308};
309
310/*
311 * Configuration
312 */
313
314struct rte_sched_port;
315
323void
324rte_sched_port_free(struct rte_sched_port *port);
325
334struct rte_sched_port *
337
352int
353rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
354 uint32_t subport_id,
355 struct rte_sched_pipe_params *params,
356 uint32_t *pipe_profile_id);
357
372int
373rte_sched_port_subport_profile_add(struct rte_sched_port *port,
374 struct rte_sched_subport_profile_params *profile,
375 uint32_t *subport_profile_id);
376
395int
396rte_sched_subport_config(struct rte_sched_port *port,
397 uint32_t subport_id,
398 struct rte_sched_subport_params *params,
399 uint32_t subport_profile_id);
400
415int
416rte_sched_pipe_config(struct rte_sched_port *port,
417 uint32_t subport_id,
418 uint32_t pipe_id,
419 int32_t pipe_profile);
420
431uint32_t
433 struct rte_sched_subport_params **subport_params);
434
435/*
436 * Statistics
437 */
438
456int
457rte_sched_subport_read_stats(struct rte_sched_port *port,
458 uint32_t subport_id,
459 struct rte_sched_subport_stats *stats,
460 uint32_t *tc_ov);
461
478int
479rte_sched_queue_read_stats(struct rte_sched_port *port,
480 uint32_t queue_id,
481 struct rte_sched_queue_stats *stats,
482 uint16_t *qlen);
483
504void
505rte_sched_port_pkt_write(struct rte_sched_port *port,
506 struct rte_mbuf *pkt,
507 uint32_t subport, uint32_t pipe, uint32_t traffic_class,
508 uint32_t queue, enum rte_color color);
509
530void
531rte_sched_port_pkt_read_tree_path(struct rte_sched_port *port,
532 const struct rte_mbuf *pkt,
533 uint32_t *subport, uint32_t *pipe,
534 uint32_t *traffic_class, uint32_t *queue);
535
536enum rte_color
537rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt);
538
557int
558rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
559
577int
578rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts);
579
594int
595rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable);
596
597#ifdef __cplusplus
598}
599#endif
600
601#endif /* __INCLUDE_RTE_SCHED_H__ */
#define __rte_dealloc(dealloc, argno)
Definition: rte_common.h:301
#define __rte_malloc
Definition: rte_common.h:290
rte_color
Definition: rte_meter.h:32
@ RTE_COLORS
Definition: rte_meter.h:36
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_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)
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 rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params, struct rte_sched_subport_params **subport_params)
#define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
Definition: rte_sched.h:86
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)
int rte_sched_subport_tc_ov_config(struct rte_sched_port *port, uint32_t subport_id, bool tc_ov_enable)
int rte_sched_subport_config(struct rte_sched_port *port, uint32_t subport_id, struct rte_sched_subport_params *params, uint32_t subport_profile_id)
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_BE_QUEUES_PER_PIPE
Definition: rte_sched.h:80
struct rte_sched_port * rte_sched_port_config(struct rte_sched_port_params *params) __rte_malloc __rte_dealloc(rte_sched_port_free
struct rte_sched_port 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)
int rte_sched_port_subport_profile_add(struct rte_sched_port *port, struct rte_sched_subport_profile_params *profile, uint32_t *subport_profile_id)
int rte_sched_port_dequeue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
rte_sched_cman_mode
Definition: rte_sched.h:127
@ RTE_SCHED_CMAN_PIE
Definition: rte_sched.h:129
@ RTE_SCHED_CMAN_RED
Definition: rte_sched.h:128
uint32_t frame_overhead
Definition: rte_sched.h:286
uint32_t n_subport_profiles
Definition: rte_sched.h:297
struct rte_sched_subport_profile_params * subport_profiles
Definition: rte_sched.h:294
uint32_t n_subports_per_port
Definition: rte_sched.h:289
const char * name
Definition: rte_sched.h:272
uint32_t n_pipes_per_subport
Definition: rte_sched.h:307
uint32_t n_max_subport_profiles
Definition: rte_sched.h:300
uint64_t n_pkts_dropped
Definition: rte_sched.h:257
uint64_t n_pkts_cman_dropped
Definition: rte_sched.h:260
uint64_t n_bytes_dropped
Definition: rte_sched.h:266
uint64_t n_bytes_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:242
uint64_t n_pkts_tc[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:236
uint64_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:245
uint64_t n_pkts_cman_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:248
uint64_t n_pkts_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
Definition: rte_sched.h:239