xref: /linux-6.15/include/linux/if_link.h (revision edbc0bb3)
1 #ifndef _LINUX_IF_LINK_H
2 #define _LINUX_IF_LINK_H
3 
4 #include <linux/types.h>
5 #include <linux/netlink.h>
6 
7 /* This struct should be in sync with struct rtnl_link_stats64 */
8 struct rtnl_link_stats {
9 	__u32	rx_packets;		/* total packets received	*/
10 	__u32	tx_packets;		/* total packets transmitted	*/
11 	__u32	rx_bytes;		/* total bytes received 	*/
12 	__u32	tx_bytes;		/* total bytes transmitted	*/
13 	__u32	rx_errors;		/* bad packets received		*/
14 	__u32	tx_errors;		/* packet transmit problems	*/
15 	__u32	rx_dropped;		/* no space in linux buffers	*/
16 	__u32	tx_dropped;		/* no space available in linux	*/
17 	__u32	multicast;		/* multicast packets received	*/
18 	__u32	collisions;
19 
20 	/* detailed rx_errors: */
21 	__u32	rx_length_errors;
22 	__u32	rx_over_errors;		/* receiver ring buff overflow	*/
23 	__u32	rx_crc_errors;		/* recved pkt with crc error	*/
24 	__u32	rx_frame_errors;	/* recv'd frame alignment error */
25 	__u32	rx_fifo_errors;		/* recv'r fifo overrun		*/
26 	__u32	rx_missed_errors;	/* receiver missed packet	*/
27 
28 	/* detailed tx_errors */
29 	__u32	tx_aborted_errors;
30 	__u32	tx_carrier_errors;
31 	__u32	tx_fifo_errors;
32 	__u32	tx_heartbeat_errors;
33 	__u32	tx_window_errors;
34 
35 	/* for cslip etc */
36 	__u32	rx_compressed;
37 	__u32	tx_compressed;
38 };
39 
40 /* The main device statistics structure */
41 struct rtnl_link_stats64 {
42 	__u64	rx_packets;		/* total packets received	*/
43 	__u64	tx_packets;		/* total packets transmitted	*/
44 	__u64	rx_bytes;		/* total bytes received 	*/
45 	__u64	tx_bytes;		/* total bytes transmitted	*/
46 	__u64	rx_errors;		/* bad packets received		*/
47 	__u64	tx_errors;		/* packet transmit problems	*/
48 	__u64	rx_dropped;		/* no space in linux buffers	*/
49 	__u64	tx_dropped;		/* no space available in linux	*/
50 	__u64	multicast;		/* multicast packets received	*/
51 	__u64	collisions;
52 
53 	/* detailed rx_errors: */
54 	__u64	rx_length_errors;
55 	__u64	rx_over_errors;		/* receiver ring buff overflow	*/
56 	__u64	rx_crc_errors;		/* recved pkt with crc error	*/
57 	__u64	rx_frame_errors;	/* recv'd frame alignment error */
58 	__u64	rx_fifo_errors;		/* recv'r fifo overrun		*/
59 	__u64	rx_missed_errors;	/* receiver missed packet	*/
60 
61 	/* detailed tx_errors */
62 	__u64	tx_aborted_errors;
63 	__u64	tx_carrier_errors;
64 	__u64	tx_fifo_errors;
65 	__u64	tx_heartbeat_errors;
66 	__u64	tx_window_errors;
67 
68 	/* for cslip etc */
69 	__u64	rx_compressed;
70 	__u64	tx_compressed;
71 };
72 
73 /* The struct should be in sync with struct ifmap */
74 struct rtnl_link_ifmap {
75 	__u64	mem_start;
76 	__u64	mem_end;
77 	__u64	base_addr;
78 	__u16	irq;
79 	__u8	dma;
80 	__u8	port;
81 };
82 
83 /*
84  * IFLA_AF_SPEC
85  *   Contains nested attributes for address family specific attributes.
86  *   Each address family may create a attribute with the address family
87  *   number as type and create its own attribute structure in it.
88  *
89  *   Example:
90  *   [IFLA_AF_SPEC] = {
91  *       [AF_INET] = {
92  *           [IFLA_INET_CONF] = ...,
93  *       },
94  *       [AF_INET6] = {
95  *           [IFLA_INET6_FLAGS] = ...,
96  *           [IFLA_INET6_CONF] = ...,
97  *       }
98  *   }
99  */
100 
101 enum {
102 	IFLA_UNSPEC,
103 	IFLA_ADDRESS,
104 	IFLA_BROADCAST,
105 	IFLA_IFNAME,
106 	IFLA_MTU,
107 	IFLA_LINK,
108 	IFLA_QDISC,
109 	IFLA_STATS,
110 	IFLA_COST,
111 #define IFLA_COST IFLA_COST
112 	IFLA_PRIORITY,
113 #define IFLA_PRIORITY IFLA_PRIORITY
114 	IFLA_MASTER,
115 #define IFLA_MASTER IFLA_MASTER
116 	IFLA_WIRELESS,		/* Wireless Extension event - see wireless.h */
117 #define IFLA_WIRELESS IFLA_WIRELESS
118 	IFLA_PROTINFO,		/* Protocol specific information for a link */
119 #define IFLA_PROTINFO IFLA_PROTINFO
120 	IFLA_TXQLEN,
121 #define IFLA_TXQLEN IFLA_TXQLEN
122 	IFLA_MAP,
123 #define IFLA_MAP IFLA_MAP
124 	IFLA_WEIGHT,
125 #define IFLA_WEIGHT IFLA_WEIGHT
126 	IFLA_OPERSTATE,
127 	IFLA_LINKMODE,
128 	IFLA_LINKINFO,
129 #define IFLA_LINKINFO IFLA_LINKINFO
130 	IFLA_NET_NS_PID,
131 	IFLA_IFALIAS,
132 	IFLA_NUM_VF,		/* Number of VFs if device is SR-IOV PF */
133 	IFLA_VFINFO_LIST,
134 	IFLA_STATS64,
135 	IFLA_VF_PORTS,
136 	IFLA_PORT_SELF,
137 	IFLA_AF_SPEC,
138 	IFLA_GROUP,		/* Group the device belongs to */
139 	IFLA_NET_NS_FD,
140 	IFLA_EXT_MASK,		/* Extended info mask, VFs, etc */
141 	IFLA_PROMISCUITY,	/* Promiscuity count: > 0 means acts PROMISC */
142 #define IFLA_PROMISCUITY IFLA_PROMISCUITY
143 	__IFLA_MAX
144 };
145 
146 
147 #define IFLA_MAX (__IFLA_MAX - 1)
148 
149 /* backwards compatibility for userspace */
150 #ifndef __KERNEL__
151 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
152 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
153 #endif
154 
155 enum {
156 	IFLA_INET_UNSPEC,
157 	IFLA_INET_CONF,
158 	__IFLA_INET_MAX,
159 };
160 
161 #define IFLA_INET_MAX (__IFLA_INET_MAX - 1)
162 
163 /* ifi_flags.
164 
165    IFF_* flags.
166 
167    The only change is:
168    IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
169    more not changeable by user. They describe link media
170    characteristics and set by device driver.
171 
172    Comments:
173    - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
174    - If neither of these three flags are set;
175      the interface is NBMA.
176 
177    - IFF_MULTICAST does not mean anything special:
178    multicasts can be used on all not-NBMA links.
179    IFF_MULTICAST means that this media uses special encapsulation
180    for multicast frames. Apparently, all IFF_POINTOPOINT and
181    IFF_BROADCAST devices are able to use multicasts too.
182  */
183 
184 /* IFLA_LINK.
185    For usual devices it is equal ifi_index.
186    If it is a "virtual interface" (f.e. tunnel), ifi_link
187    can point to real physical interface (f.e. for bandwidth calculations),
188    or maybe 0, what means, that real media is unknown (usual
189    for IPIP tunnels, when route to endpoint is allowed to change)
190  */
191 
192 /* Subtype attributes for IFLA_PROTINFO */
193 enum {
194 	IFLA_INET6_UNSPEC,
195 	IFLA_INET6_FLAGS,	/* link flags			*/
196 	IFLA_INET6_CONF,	/* sysctl parameters		*/
197 	IFLA_INET6_STATS,	/* statistics			*/
198 	IFLA_INET6_MCAST,	/* MC things. What of them?	*/
199 	IFLA_INET6_CACHEINFO,	/* time values and max reasm size */
200 	IFLA_INET6_ICMP6STATS,	/* statistics (icmpv6)		*/
201 	__IFLA_INET6_MAX
202 };
203 
204 #define IFLA_INET6_MAX	(__IFLA_INET6_MAX - 1)
205 
206 struct ifla_cacheinfo {
207 	__u32	max_reasm_len;
208 	__u32	tstamp;		/* ipv6InterfaceTable updated timestamp */
209 	__u32	reachable_time;
210 	__u32	retrans_time;
211 };
212 
213 enum {
214 	IFLA_INFO_UNSPEC,
215 	IFLA_INFO_KIND,
216 	IFLA_INFO_DATA,
217 	IFLA_INFO_XSTATS,
218 	__IFLA_INFO_MAX,
219 };
220 
221 #define IFLA_INFO_MAX	(__IFLA_INFO_MAX - 1)
222 
223 /* VLAN section */
224 
225 enum {
226 	IFLA_VLAN_UNSPEC,
227 	IFLA_VLAN_ID,
228 	IFLA_VLAN_FLAGS,
229 	IFLA_VLAN_EGRESS_QOS,
230 	IFLA_VLAN_INGRESS_QOS,
231 	__IFLA_VLAN_MAX,
232 };
233 
234 #define IFLA_VLAN_MAX	(__IFLA_VLAN_MAX - 1)
235 
236 struct ifla_vlan_flags {
237 	__u32	flags;
238 	__u32	mask;
239 };
240 
241 enum {
242 	IFLA_VLAN_QOS_UNSPEC,
243 	IFLA_VLAN_QOS_MAPPING,
244 	__IFLA_VLAN_QOS_MAX
245 };
246 
247 #define IFLA_VLAN_QOS_MAX	(__IFLA_VLAN_QOS_MAX - 1)
248 
249 struct ifla_vlan_qos_mapping {
250 	__u32 from;
251 	__u32 to;
252 };
253 
254 /* MACVLAN section */
255 enum {
256 	IFLA_MACVLAN_UNSPEC,
257 	IFLA_MACVLAN_MODE,
258 	__IFLA_MACVLAN_MAX,
259 };
260 
261 #define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1)
262 
263 enum macvlan_mode {
264 	MACVLAN_MODE_PRIVATE = 1, /* don't talk to other macvlans */
265 	MACVLAN_MODE_VEPA    = 2, /* talk to other ports through ext bridge */
266 	MACVLAN_MODE_BRIDGE  = 4, /* talk to bridge ports directly */
267 	MACVLAN_MODE_PASSTHRU = 8,/* take over the underlying device */
268 };
269 
270 /* SR-IOV virtual function management section */
271 
272 enum {
273 	IFLA_VF_INFO_UNSPEC,
274 	IFLA_VF_INFO,
275 	__IFLA_VF_INFO_MAX,
276 };
277 
278 #define IFLA_VF_INFO_MAX (__IFLA_VF_INFO_MAX - 1)
279 
280 enum {
281 	IFLA_VF_UNSPEC,
282 	IFLA_VF_MAC,		/* Hardware queue specific attributes */
283 	IFLA_VF_VLAN,
284 	IFLA_VF_TX_RATE,	/* TX Bandwidth Allocation */
285 	IFLA_VF_SPOOFCHK,	/* Spoof Checking on/off switch */
286 	__IFLA_VF_MAX,
287 };
288 
289 #define IFLA_VF_MAX (__IFLA_VF_MAX - 1)
290 
291 struct ifla_vf_mac {
292 	__u32 vf;
293 	__u8 mac[32]; /* MAX_ADDR_LEN */
294 };
295 
296 struct ifla_vf_vlan {
297 	__u32 vf;
298 	__u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
299 	__u32 qos;
300 };
301 
302 struct ifla_vf_tx_rate {
303 	__u32 vf;
304 	__u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */
305 };
306 
307 struct ifla_vf_spoofchk {
308 	__u32 vf;
309 	__u32 setting;
310 };
311 #ifdef __KERNEL__
312 
313 /* We don't want this structure exposed to user space */
314 struct ifla_vf_info {
315 	__u32 vf;
316 	__u8 mac[32];
317 	__u32 vlan;
318 	__u32 qos;
319 	__u32 tx_rate;
320 	__u32 spoofchk;
321 };
322 #endif
323 
324 /* VF ports management section
325  *
326  *	Nested layout of set/get msg is:
327  *
328  *		[IFLA_NUM_VF]
329  *		[IFLA_VF_PORTS]
330  *			[IFLA_VF_PORT]
331  *				[IFLA_PORT_*], ...
332  *			[IFLA_VF_PORT]
333  *				[IFLA_PORT_*], ...
334  *			...
335  *		[IFLA_PORT_SELF]
336  *			[IFLA_PORT_*], ...
337  */
338 
339 enum {
340 	IFLA_VF_PORT_UNSPEC,
341 	IFLA_VF_PORT,			/* nest */
342 	__IFLA_VF_PORT_MAX,
343 };
344 
345 #define IFLA_VF_PORT_MAX (__IFLA_VF_PORT_MAX - 1)
346 
347 enum {
348 	IFLA_PORT_UNSPEC,
349 	IFLA_PORT_VF,			/* __u32 */
350 	IFLA_PORT_PROFILE,		/* string */
351 	IFLA_PORT_VSI_TYPE,		/* 802.1Qbg (pre-)standard VDP */
352 	IFLA_PORT_INSTANCE_UUID,	/* binary UUID */
353 	IFLA_PORT_HOST_UUID,		/* binary UUID */
354 	IFLA_PORT_REQUEST,		/* __u8 */
355 	IFLA_PORT_RESPONSE,		/* __u16, output only */
356 	__IFLA_PORT_MAX,
357 };
358 
359 #define IFLA_PORT_MAX (__IFLA_PORT_MAX - 1)
360 
361 #define PORT_PROFILE_MAX	40
362 #define PORT_UUID_MAX		16
363 #define PORT_SELF_VF		-1
364 
365 enum {
366 	PORT_REQUEST_PREASSOCIATE = 0,
367 	PORT_REQUEST_PREASSOCIATE_RR,
368 	PORT_REQUEST_ASSOCIATE,
369 	PORT_REQUEST_DISASSOCIATE,
370 };
371 
372 enum {
373 	PORT_VDP_RESPONSE_SUCCESS = 0,
374 	PORT_VDP_RESPONSE_INVALID_FORMAT,
375 	PORT_VDP_RESPONSE_INSUFFICIENT_RESOURCES,
376 	PORT_VDP_RESPONSE_UNUSED_VTID,
377 	PORT_VDP_RESPONSE_VTID_VIOLATION,
378 	PORT_VDP_RESPONSE_VTID_VERSION_VIOALTION,
379 	PORT_VDP_RESPONSE_OUT_OF_SYNC,
380 	/* 0x08-0xFF reserved for future VDP use */
381 	PORT_PROFILE_RESPONSE_SUCCESS = 0x100,
382 	PORT_PROFILE_RESPONSE_INPROGRESS,
383 	PORT_PROFILE_RESPONSE_INVALID,
384 	PORT_PROFILE_RESPONSE_BADSTATE,
385 	PORT_PROFILE_RESPONSE_INSUFFICIENT_RESOURCES,
386 	PORT_PROFILE_RESPONSE_ERROR,
387 };
388 
389 struct ifla_port_vsi {
390 	__u8 vsi_mgr_id;
391 	__u8 vsi_type_id[3];
392 	__u8 vsi_type_version;
393 	__u8 pad[3];
394 };
395 
396 #endif /* _LINUX_IF_LINK_H */
397