libnl: /data/src/libnl/lib/route/nl-route.h Source File

libnl 3.12.0

nl-route.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
4 * Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
5 */
6
7#ifndef __LIB_ROUTE_NL_ROUTE_H__
8#define __LIB_ROUTE_NL_ROUTE_H__
9
10#include <netlink/route/tc.h>
11
12#include "nl-priv-dynamic-core/object-api.h"
13#include "nl-priv-dynamic-route/nl-priv-dynamic-route.h"
14#include "nl-aux-core/nl-core.h"
15
16/*****************************************************************************/
17
18 struct rtnl_link_map {
19 uint64_t lm_mem_start;
20 uint64_t lm_mem_end;
21 uint64_t lm_base_addr;
22 uint16_t lm_irq;
23 uint8_t lm_dma;
24 uint8_t lm_port;
25};
26
27#define IFQDISCSIZ 32
28
29 struct rtnl_link {
30 NLHDR_COMMON
31
32 char l_name[IFNAMSIZ];
33 uint32_t l_family;
34 uint32_t l_arptype;
35 uint32_t l_index;
36 uint32_t l_flags;
37 uint32_t l_change;
38 uint32_t l_mtu;
39 uint32_t l_link;
40 int32_t l_link_netnsid;
41 uint32_t l_txqlen;
42 uint32_t l_weight;
43 uint32_t l_master;
44 struct nl_addr *l_addr;
45 struct nl_addr *l_bcast;
46 struct nl_addr *l_paddr;
47 char l_qdisc[IFQDISCSIZ];
48 struct rtnl_link_map l_map;
49 uint64_t l_stats[RTNL_LINK_STATS_MAX + 1];
50 uint32_t l_flag_mask;
51 uint32_t l_num_vf;
52 uint8_t l_operstate;
53 uint8_t l_linkmode;
54 /* 2 byte hole */
55 char *l_info_kind;
56 char *l_info_slave_kind;
57 struct rtnl_link_info_ops *l_info_ops;
58 void *l_af_data[AF_MAX];
59 void *l_info;
60 char *l_ifalias;
61 uint32_t l_promiscuity;
62 uint32_t l_num_tx_queues;
63 uint32_t l_num_rx_queues;
64 uint32_t l_gso_max_segs;
65 uint32_t l_gso_max_size;
66 uint32_t l_group;
67 uint8_t l_carrier;
68 /* 3 byte hole */
69 uint32_t l_carrier_changes;
70 struct rtnl_link_af_ops *l_af_ops;
71 struct nl_data *l_phys_port_id;
72 char l_phys_port_name[IFNAMSIZ];
73 struct nl_data *l_phys_switch_id;
74 int l_ns_fd;
75 pid_t l_ns_pid;
76 struct rtnl_link_vf *l_vf_list;
77};
78
79 struct rtnl_nh_encap {
80 const struct nh_encap_ops *ops;
81 void *priv; /* private data for encap type */
82};
83
84 struct rtnl_ratespec {
85 uint64_t rs_rate64;
86 uint16_t rs_overhead;
87 int16_t rs_cell_align;
88 uint16_t rs_mpu;
89 uint8_t rs_cell_log;
90};
91
92#define TCKINDSIZ 32
93
94#define NL_TC_GENERIC(pre) \
95 NLHDR_COMMON \
96 uint32_t pre##_family; \
97 uint32_t pre##_ifindex; \
98 uint32_t pre##_handle; \
99 uint32_t pre##_parent; \
100 uint32_t pre##_info; \
101 uint32_t pre##_mtu; \
102 uint32_t pre##_mpu; \
103 uint32_t pre##_overhead; \
104 uint32_t pre##_linktype; \
105 char pre##_kind[TCKINDSIZ]; \
106 struct nl_data *pre##_opts; \
107 uint64_t pre##_stats[RTNL_TC_STATS_MAX + 1]; \
108 struct nl_data *pre##_xstats; \
109 struct nl_data *pre##_subdata; \
110 struct rtnl_link *pre##_link; \
111 struct rtnl_tc_ops *pre##_ops; \
112 enum rtnl_tc_type pre##_type; \
113 uint32_t pre##_chain
114
115 struct rtnl_tc {
116 NL_TC_GENERIC(tc);
117};
118
119 struct rtnl_qdisc {
120 NL_TC_GENERIC(q);
121};
122
123 struct rtnl_act {
124 NL_TC_GENERIC(c);
125 struct rtnl_act *a_next;
126};
127
128/*****************************************************************************/
129
130static inline void rtnl_copy_ratespec(struct rtnl_ratespec *dst,
131 struct tc_ratespec *src)
132{
133 dst->rs_cell_log = src->cell_log;
134 dst->rs_overhead = src->overhead;
135 dst->rs_cell_align = src->cell_align;
136 dst->rs_mpu = src->mpu;
137 dst->rs_rate64 = src->rate;
138}
139
140static inline void rtnl_rcopy_ratespec(struct tc_ratespec *dst,
141 struct rtnl_ratespec *src)
142{
143 dst->cell_log = src->rs_cell_log;
144 dst->overhead = src->rs_overhead;
145 dst->cell_align = src->rs_cell_align;
146 dst->mpu = src->rs_mpu;
147 dst->rate = src->rs_rate64 > 0xFFFFFFFFull ? 0xFFFFFFFFull :
148 (uint32_t)src->rs_rate64;
149}
150
151/*****************************************************************************/
152
153static inline int build_sysconf_path(char **strp, const char *filename)
154{
155 char *sysconfdir;
156
157 sysconfdir = getenv("NLSYSCONFDIR");
158
159 if (!sysconfdir)
160 sysconfdir = _NL_SYSCONFDIR_LIBNL;
161
162 return asprintf(strp, "%s/%s", sysconfdir, filename);
163}
164
165/*****************************************************************************/
166
167static inline int rtnl_tc_calc_txtime64(int bufsize, uint64_t rate)
168{
169 return ((double)bufsize / (double)rate) * 1000000.0;
170}
171
172static inline int rtnl_tc_calc_bufsize64(int txtime, uint64_t rate)
173{
174 return ((double)txtime * (double)rate) / 1000000.0;
175}
176
177#endif /* __LIB_ROUTE_NL_ROUTE_H__ */
nh_encap_ops
Definition nexthop-encap.h:6
rtnl_act
Definition nl-route.h:123
rtnl_link_af_ops
Available operations to modules implementing a link address family.
Definition link-api.h:76
rtnl_link_info_ops
Available operations to modules implementing a link info type.
Definition link-api.h:20
rtnl_link_map
Definition nl-route.h:18
rtnl_link_vf
SRIOV VF object.
rtnl_link
Link object.
Definition nl-route.h:29
rtnl_nh_encap
Definition nl-route.h:79
rtnl_qdisc
Definition nl-route.h:119
rtnl_ratespec
Definition nl-route.h:84
rtnl_tc
Definition nl-route.h:115