libnl: /data/src/libnl3/include/netlink/route/tc.h Source File

libnl 3.10.0

tc.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch>
4 */
5
6#ifndef NETLINK_TC_H_
7#define NETLINK_TC_H_
8
9#include <netlink/netlink.h>
10#include <netlink/cache.h>
11#include <netlink/data.h>
12#include <netlink/route/link.h>
13#include <linux/pkt_sched.h>
14#include <linux/pkt_cls.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20enum rtnl_tc_type {
21 RTNL_TC_TYPE_QDISC,
22 RTNL_TC_TYPE_CLASS,
23 RTNL_TC_TYPE_CLS,
24 RTNL_TC_TYPE_ACT,
25 __RTNL_TC_TYPE_MAX,
26};
27
28#define RTNL_TC_TYPE_MAX (__RTNL_TC_TYPE_MAX - 1)
29
30/**
31 * Compute tc handle based on major and minor parts
32 * @ingroup tc
33 */
34#define TC_HANDLE(maj, min) (TC_H_MAJ((maj) << 16) | TC_H_MIN(min))
35
36/**
37 * Traffic control object
38 * @ingroup tc
39 */
40struct rtnl_tc;
41
42/**
43 * Macro to cast qdisc/class/classifier to tc object
44 * @ingroup tc
45 *
46 * @code
47 * rtnl_tc_set_mpu(TC_CAST(qdisc), 40);
48 * @endcode
49 */
50#define TC_CAST(ptr) ((struct rtnl_tc *) (ptr))
51
52/**
53 * Traffic control statistical identifier
54 * @ingroup tc
55 *
56 * @code
57 * uint64_t n = rtnl_tc_get_stat(TC_CAST(class), RTNL_TC_PACKETS);
58 * @endcode
59 */
60 enum rtnl_tc_stat {
61 RTNL_TC_PACKETS, /**< Number of packets seen */
62 RTNL_TC_BYTES, /**< Total bytes seen */
63 RTNL_TC_RATE_BPS, /**< Current bits/s (rate estimator) */
64 RTNL_TC_RATE_PPS, /**< Current packet/s (rate estimator) */
65 RTNL_TC_QLEN, /**< Current queue length */
66 RTNL_TC_BACKLOG, /**< Current backlog length */
67 RTNL_TC_DROPS, /**< Total number of packets dropped */
68 RTNL_TC_REQUEUES, /**< Total number of requeues */
69 RTNL_TC_OVERLIMITS, /**< Total number of overlimits */
70 __RTNL_TC_STATS_MAX,
71};
72
73#define RTNL_TC_STATS_MAX (__RTNL_TC_STATS_MAX - 1)
74
75extern void rtnl_tc_set_ifindex(struct rtnl_tc *, int);
76extern int rtnl_tc_get_ifindex(struct rtnl_tc *);
77extern void rtnl_tc_set_link(struct rtnl_tc *, struct rtnl_link *);
78extern struct rtnl_link *rtnl_tc_get_link(struct rtnl_tc *);
79extern void rtnl_tc_set_mtu(struct rtnl_tc *, uint32_t);
80extern uint32_t rtnl_tc_get_mtu(struct rtnl_tc *);
81extern void rtnl_tc_set_mpu(struct rtnl_tc *, uint32_t);
82extern uint32_t rtnl_tc_get_mpu(struct rtnl_tc *);
83extern void rtnl_tc_set_overhead(struct rtnl_tc *, uint32_t);
84extern uint32_t rtnl_tc_get_overhead(struct rtnl_tc *);
85extern void rtnl_tc_set_linktype(struct rtnl_tc *, uint32_t);
86extern uint32_t rtnl_tc_get_linktype(struct rtnl_tc *);
87extern void rtnl_tc_set_handle(struct rtnl_tc *, uint32_t);
88extern uint32_t rtnl_tc_get_handle(struct rtnl_tc *);
89extern void rtnl_tc_set_parent(struct rtnl_tc *, uint32_t);
90extern uint32_t rtnl_tc_get_parent(struct rtnl_tc *);
91extern int rtnl_tc_set_kind(struct rtnl_tc *, const char *);
92extern char * rtnl_tc_get_kind(struct rtnl_tc *);
93extern uint64_t rtnl_tc_get_stat(struct rtnl_tc *, enum rtnl_tc_stat);
94extern char * rtnl_tc_stat2str(enum rtnl_tc_stat, char *, size_t);
95extern int rtnl_tc_str2stat(const char *);
96
97extern int rtnl_tc_calc_txtime(int, int);
98extern int rtnl_tc_calc_bufsize(int, int);
99extern int rtnl_tc_calc_cell_log(int);
100
101extern int rtnl_tc_read_classid_file(void);
102extern char * rtnl_tc_handle2str(uint32_t, char *, size_t);
103extern int rtnl_tc_str2handle(const char *, uint32_t *);
104extern int rtnl_classid_generate(const char *, uint32_t *,
105 uint32_t);
106extern void rtnl_tc_set_chain(struct rtnl_tc *, uint32_t);
107extern int rtnl_tc_get_chain(struct rtnl_tc *, uint32_t *);
108
109#ifdef __cplusplus
110}
111#endif
112
113#endif
rtnl_tc_str2handle
int rtnl_tc_str2handle(const char *, uint32_t *)
Convert a charactering strint to a traffic control handle.
Definition classid.c:154
rtnl_tc_handle2str
char * rtnl_tc_handle2str(uint32_t, char *, size_t)
Convert a traffic control handle to a character string (Reentrant).
Definition classid.c:109
rtnl_tc_read_classid_file
int rtnl_tc_read_classid_file(void)
(Re-)read classid file
Definition classid.c:311
rtnl_tc_set_mpu
void rtnl_tc_set_mpu(struct rtnl_tc *, uint32_t)
Set the Minimum Packet Unit (MPU) of a traffic control object.
Definition tc.c:398
rtnl_tc_get_parent
uint32_t rtnl_tc_get_parent(struct rtnl_tc *)
Return parent identifier of a traffic control object.
Definition tc.c:516
rtnl_tc_set_linktype
void rtnl_tc_set_linktype(struct rtnl_tc *, uint32_t)
Set the linktype of a traffic control object.
Definition tc.c:455
rtnl_tc_set_kind
int rtnl_tc_set_kind(struct rtnl_tc *, const char *)
Define the type of traffic control object.
Definition tc.c:528
rtnl_tc_calc_cell_log
int rtnl_tc_calc_cell_log(int)
Calculate the binary logarithm for a specific cell size.
Definition tc.c:676
rtnl_tc_get_chain
int rtnl_tc_get_chain(struct rtnl_tc *, uint32_t *)
Return chain index of traffic control object.
Definition tc.c:596
rtnl_tc_get_kind
char * rtnl_tc_get_kind(struct rtnl_tc *)
Return kind of traffic control object.
Definition tc.c:553
rtnl_tc_set_ifindex
void rtnl_tc_set_ifindex(struct rtnl_tc *, int)
Set interface index of traffic control object.
Definition tc.c:277
rtnl_tc_set_overhead
void rtnl_tc_set_overhead(struct rtnl_tc *, uint32_t)
Set per packet overhead of a traffic control object.
Definition tc.c:427
rtnl_tc_calc_bufsize
int rtnl_tc_calc_bufsize(int, int)
Calculate buffer size able to transmit in a specific time and rate.
Definition tc.c:666
rtnl_tc_get_mtu
uint32_t rtnl_tc_get_mtu(struct rtnl_tc *)
Return the MTU of traffic control object.
Definition tc.c:378
rtnl_tc_get_ifindex
int rtnl_tc_get_ifindex(struct rtnl_tc *)
Return interface index of traffic control object.
Definition tc.c:292
rtnl_tc_set_link
void rtnl_tc_set_link(struct rtnl_tc *, struct rtnl_link *)
Set link of traffic control object.
Definition tc.c:309
rtnl_tc_get_handle
uint32_t rtnl_tc_get_handle(struct rtnl_tc *)
Return identifier of a traffic control object.
Definition tc.c:495
rtnl_tc_get_overhead
uint32_t rtnl_tc_get_overhead(struct rtnl_tc *)
Return per packet overhead of a traffic control object.
Definition tc.c:439
rtnl_tc_set_handle
void rtnl_tc_set_handle(struct rtnl_tc *, uint32_t)
Set identifier of traffic control object.
Definition tc.c:485
rtnl_tc_set_parent
void rtnl_tc_set_parent(struct rtnl_tc *, uint32_t)
Set the parent identifier of a traffic control object.
Definition tc.c:506
rtnl_tc_set_mtu
void rtnl_tc_set_mtu(struct rtnl_tc *, uint32_t)
Set the Maximum Transmission Unit (MTU) of traffic control object.
Definition tc.c:363
rtnl_tc_set_chain
void rtnl_tc_set_chain(struct rtnl_tc *, uint32_t)
Set the chain index of a traffic control object.
Definition tc.c:582
rtnl_tc_get_stat
uint64_t rtnl_tc_get_stat(struct rtnl_tc *, enum rtnl_tc_stat)
Return value of a statistical counter of a traffic control object.
Definition tc.c:568
rtnl_tc_stat
rtnl_tc_stat
Traffic control statistical identifier.
Definition tc.h:60
rtnl_tc_get_link
struct rtnl_link * rtnl_tc_get_link(struct rtnl_tc *)
Get link of traffic control object.
Definition tc.c:340
rtnl_tc_get_linktype
uint32_t rtnl_tc_get_linktype(struct rtnl_tc *)
Return the linktype of a traffic control object.
Definition tc.c:470
rtnl_tc_get_mpu
uint32_t rtnl_tc_get_mpu(struct rtnl_tc *)
Return the Minimum Packet Unit (MPU) of a traffic control object.
Definition tc.c:410
rtnl_tc_calc_txtime
int rtnl_tc_calc_txtime(int, int)
Calculate time required to transmit buffer at a specific rate.
Definition tc.c:647
RTNL_TC_PACKETS
@ RTNL_TC_PACKETS
Number of packets seen.
Definition tc.h:61
RTNL_TC_BYTES
@ RTNL_TC_BYTES
Total bytes seen.
Definition tc.h:62
RTNL_TC_QLEN
@ RTNL_TC_QLEN
Current queue length.
Definition tc.h:65
RTNL_TC_OVERLIMITS
@ RTNL_TC_OVERLIMITS
Total number of overlimits.
Definition tc.h:69
RTNL_TC_DROPS
@ RTNL_TC_DROPS
Total number of packets dropped.
Definition tc.h:67
RTNL_TC_RATE_PPS
@ RTNL_TC_RATE_PPS
Current packet/s (rate estimator)
Definition tc.h:64
RTNL_TC_REQUEUES
@ RTNL_TC_REQUEUES
Total number of requeues.
Definition tc.h:68
RTNL_TC_BACKLOG
@ RTNL_TC_BACKLOG
Current backlog length.
Definition tc.h:66
RTNL_TC_RATE_BPS
@ RTNL_TC_RATE_BPS
Current bits/s (rate estimator)
Definition tc.h:63
rtnl_link
Link object.
Definition nl-route.h:29
rtnl_tc
Definition nl-route.h:114