xref: /OK3568_Linux_fs/kernel/include/uapi/linux/errqueue.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun #ifndef _UAPI_LINUX_ERRQUEUE_H
3*4882a593Smuzhiyun #define _UAPI_LINUX_ERRQUEUE_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/types.h>
6*4882a593Smuzhiyun #include <linux/time_types.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun /* RFC 4884: return offset to extension struct + validation */
9*4882a593Smuzhiyun struct sock_ee_data_rfc4884 {
10*4882a593Smuzhiyun 	__u16	len;
11*4882a593Smuzhiyun 	__u8	flags;
12*4882a593Smuzhiyun 	__u8	reserved;
13*4882a593Smuzhiyun };
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun struct sock_extended_err {
16*4882a593Smuzhiyun 	__u32	ee_errno;
17*4882a593Smuzhiyun 	__u8	ee_origin;
18*4882a593Smuzhiyun 	__u8	ee_type;
19*4882a593Smuzhiyun 	__u8	ee_code;
20*4882a593Smuzhiyun 	__u8	ee_pad;
21*4882a593Smuzhiyun 	__u32   ee_info;
22*4882a593Smuzhiyun 	union	{
23*4882a593Smuzhiyun 		__u32   ee_data;
24*4882a593Smuzhiyun 		struct sock_ee_data_rfc4884 ee_rfc4884;
25*4882a593Smuzhiyun 	};
26*4882a593Smuzhiyun };
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #define SO_EE_ORIGIN_NONE	0
29*4882a593Smuzhiyun #define SO_EE_ORIGIN_LOCAL	1
30*4882a593Smuzhiyun #define SO_EE_ORIGIN_ICMP	2
31*4882a593Smuzhiyun #define SO_EE_ORIGIN_ICMP6	3
32*4882a593Smuzhiyun #define SO_EE_ORIGIN_TXSTATUS	4
33*4882a593Smuzhiyun #define SO_EE_ORIGIN_ZEROCOPY	5
34*4882a593Smuzhiyun #define SO_EE_ORIGIN_TXTIME	6
35*4882a593Smuzhiyun #define SO_EE_ORIGIN_TIMESTAMPING SO_EE_ORIGIN_TXSTATUS
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #define SO_EE_OFFENDER(ee)	((struct sockaddr*)((ee)+1))
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #define SO_EE_CODE_ZEROCOPY_COPIED	1
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define SO_EE_CODE_TXTIME_INVALID_PARAM	1
42*4882a593Smuzhiyun #define SO_EE_CODE_TXTIME_MISSED	2
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun #define SO_EE_RFC4884_FLAG_INVALID	1
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun /**
47*4882a593Smuzhiyun  *	struct scm_timestamping - timestamps exposed through cmsg
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  *	The timestamping interfaces SO_TIMESTAMPING, MSG_TSTAMP_*
50*4882a593Smuzhiyun  *	communicate network timestamps by passing this struct in a cmsg with
51*4882a593Smuzhiyun  *	recvmsg(). See Documentation/networking/timestamping.rst for details.
52*4882a593Smuzhiyun  *	User space sees a timespec definition that matches either
53*4882a593Smuzhiyun  *	__kernel_timespec or __kernel_old_timespec, in the kernel we
54*4882a593Smuzhiyun  *	require two structure definitions to provide both.
55*4882a593Smuzhiyun  */
56*4882a593Smuzhiyun struct scm_timestamping {
57*4882a593Smuzhiyun #ifdef __KERNEL__
58*4882a593Smuzhiyun 	struct __kernel_old_timespec ts[3];
59*4882a593Smuzhiyun #else
60*4882a593Smuzhiyun 	struct timespec ts[3];
61*4882a593Smuzhiyun #endif
62*4882a593Smuzhiyun };
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun struct scm_timestamping64 {
65*4882a593Smuzhiyun 	struct __kernel_timespec ts[3];
66*4882a593Smuzhiyun };
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun /* The type of scm_timestamping, passed in sock_extended_err ee_info.
69*4882a593Smuzhiyun  * This defines the type of ts[0]. For SCM_TSTAMP_SND only, if ts[0]
70*4882a593Smuzhiyun  * is zero, then this is a hardware timestamp and recorded in ts[2].
71*4882a593Smuzhiyun  */
72*4882a593Smuzhiyun enum {
73*4882a593Smuzhiyun 	SCM_TSTAMP_SND,		/* driver passed skb to NIC, or HW */
74*4882a593Smuzhiyun 	SCM_TSTAMP_SCHED,	/* data entered the packet scheduler */
75*4882a593Smuzhiyun 	SCM_TSTAMP_ACK,		/* data acknowledged by peer */
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun #endif /* _UAPI_LINUX_ERRQUEUE_H */
79