aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include/uapi/linux
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-07-30 05:15:13 -0400
committerIngo Molnar <mingo@kernel.org>2017-07-30 05:15:13 -0400
commitf5db340f19f14a8df9dfd22d71fba1513e9f1f7e (patch)
tree131d3345bc987aee3c922624de816492e7f323a4 /tools/include/uapi/linux
parentee438ec8f33c5af0d4a4ffb935c5b9272e8c2680 (diff)
parent38115f2f8cec8087d558c062e779c443a01f87d6 (diff)
Merge branch 'perf/urgent' into perf/core, to pick up latest fixes and refresh the tree
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/include/uapi/linux')
-rw-r--r--tools/include/uapi/linux/bpf.h138
1 files changed, 133 insertions, 5 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 94dfa9def355..ce2988be4f0e 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -82,6 +82,11 @@ enum bpf_cmd {
82 BPF_PROG_ATTACH, 82 BPF_PROG_ATTACH,
83 BPF_PROG_DETACH, 83 BPF_PROG_DETACH,
84 BPF_PROG_TEST_RUN, 84 BPF_PROG_TEST_RUN,
85 BPF_PROG_GET_NEXT_ID,
86 BPF_MAP_GET_NEXT_ID,
87 BPF_PROG_GET_FD_BY_ID,
88 BPF_MAP_GET_FD_BY_ID,
89 BPF_OBJ_GET_INFO_BY_FD,
85}; 90};
86 91
87enum bpf_map_type { 92enum bpf_map_type {
@@ -115,12 +120,14 @@ enum bpf_prog_type {
115 BPF_PROG_TYPE_LWT_IN, 120 BPF_PROG_TYPE_LWT_IN,
116 BPF_PROG_TYPE_LWT_OUT, 121 BPF_PROG_TYPE_LWT_OUT,
117 BPF_PROG_TYPE_LWT_XMIT, 122 BPF_PROG_TYPE_LWT_XMIT,
123 BPF_PROG_TYPE_SOCK_OPS,
118}; 124};
119 125
120enum bpf_attach_type { 126enum bpf_attach_type {
121 BPF_CGROUP_INET_INGRESS, 127 BPF_CGROUP_INET_INGRESS,
122 BPF_CGROUP_INET_EGRESS, 128 BPF_CGROUP_INET_EGRESS,
123 BPF_CGROUP_INET_SOCK_CREATE, 129 BPF_CGROUP_INET_SOCK_CREATE,
130 BPF_CGROUP_SOCK_OPS,
124 __MAX_BPF_ATTACH_TYPE 131 __MAX_BPF_ATTACH_TYPE
125}; 132};
126 133
@@ -209,6 +216,21 @@ union bpf_attr {
209 __u32 repeat; 216 __u32 repeat;
210 __u32 duration; 217 __u32 duration;
211 } test; 218 } test;
219
220 struct { /* anonymous struct used by BPF_*_GET_*_ID */
221 union {
222 __u32 start_id;
223 __u32 prog_id;
224 __u32 map_id;
225 };
226 __u32 next_id;
227 };
228
229 struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */
230 __u32 bpf_fd;
231 __u32 info_len;
232 __aligned_u64 info;
233 } info;
212} __attribute__((aligned(8))); 234} __attribute__((aligned(8)));
213 235
214/* BPF helper function descriptions: 236/* BPF helper function descriptions:
@@ -313,8 +335,11 @@ union bpf_attr {
313 * @flags: room for future extensions 335 * @flags: room for future extensions
314 * Return: 0 on success or negative error 336 * Return: 0 on success or negative error
315 * 337 *
316 * u64 bpf_perf_event_read(&map, index) 338 * u64 bpf_perf_event_read(map, flags)
317 * Return: Number events read or error code 339 * read perf event counter value
340 * @map: pointer to perf_event_array map
341 * @flags: index of event in the map or bitmask flags
342 * Return: value of perf event counter read or error code
318 * 343 *
319 * int bpf_redirect(ifindex, flags) 344 * int bpf_redirect(ifindex, flags)
320 * redirect to another netdev 345 * redirect to another netdev
@@ -328,11 +353,11 @@ union bpf_attr {
328 * @skb: pointer to skb 353 * @skb: pointer to skb
329 * Return: realm if != 0 354 * Return: realm if != 0
330 * 355 *
331 * int bpf_perf_event_output(ctx, map, index, data, size) 356 * int bpf_perf_event_output(ctx, map, flags, data, size)
332 * output perf raw sample 357 * output perf raw sample
333 * @ctx: struct pt_regs* 358 * @ctx: struct pt_regs*
334 * @map: pointer to perf_event_array map 359 * @map: pointer to perf_event_array map
335 * @index: index of event in the map 360 * @flags: index of event in the map or bitmask flags
336 * @data: data on stack to be output as raw data 361 * @data: data on stack to be output as raw data
337 * @size: size of data 362 * @size: size of data
338 * Return: 0 on success or negative error 363 * Return: 0 on success or negative error
@@ -490,6 +515,30 @@ union bpf_attr {
490 * Get the owner uid of the socket stored inside sk_buff. 515 * Get the owner uid of the socket stored inside sk_buff.
491 * @skb: pointer to skb 516 * @skb: pointer to skb
492 * Return: uid of the socket owner on success or overflowuid if failed. 517 * Return: uid of the socket owner on success or overflowuid if failed.
518 *
519 * u32 bpf_set_hash(skb, hash)
520 * Set full skb->hash.
521 * @skb: pointer to skb
522 * @hash: hash to set
523 *
524 * int bpf_setsockopt(bpf_socket, level, optname, optval, optlen)
525 * Calls setsockopt. Not all opts are available, only those with
526 * integer optvals plus TCP_CONGESTION.
527 * Supported levels: SOL_SOCKET and IPROTO_TCP
528 * @bpf_socket: pointer to bpf_socket
529 * @level: SOL_SOCKET or IPROTO_TCP
530 * @optname: option name
531 * @optval: pointer to option value
532 * @optlen: length of optval in byes
533 * Return: 0 or negative error
534 *
535 * int bpf_skb_adjust_room(skb, len_diff, mode, flags)
536 * Grow or shrink room in sk_buff.
537 * @skb: pointer to skb
538 * @len_diff: (signed) amount of room to grow/shrink
539 * @mode: operation mode (enum bpf_adj_room_mode)
540 * @flags: reserved for future use
541 * Return: 0 on success or negative error code
493 */ 542 */
494#define __BPF_FUNC_MAPPER(FN) \ 543#define __BPF_FUNC_MAPPER(FN) \
495 FN(unspec), \ 544 FN(unspec), \
@@ -539,7 +588,10 @@ union bpf_attr {
539 FN(xdp_adjust_head), \ 588 FN(xdp_adjust_head), \
540 FN(probe_read_str), \ 589 FN(probe_read_str), \
541 FN(get_socket_cookie), \ 590 FN(get_socket_cookie), \
542 FN(get_socket_uid), 591 FN(get_socket_uid), \
592 FN(set_hash), \
593 FN(setsockopt), \
594 FN(skb_adjust_room),
543 595
544/* integer value in 'imm' field of BPF_CALL instruction selects which helper 596/* integer value in 'imm' field of BPF_CALL instruction selects which helper
545 * function eBPF program intends to call 597 * function eBPF program intends to call
@@ -589,6 +641,11 @@ enum bpf_func_id {
589/* BPF_FUNC_perf_event_output for sk_buff input context. */ 641/* BPF_FUNC_perf_event_output for sk_buff input context. */
590#define BPF_F_CTXLEN_MASK (0xfffffULL << 32) 642#define BPF_F_CTXLEN_MASK (0xfffffULL << 32)
591 643
644/* Mode for BPF_FUNC_skb_adjust_room helper. */
645enum bpf_adj_room_mode {
646 BPF_ADJ_ROOM_NET_OPTS,
647};
648
592/* user accessible mirror of in-kernel sk_buff. 649/* user accessible mirror of in-kernel sk_buff.
593 * new fields can only be added to the end of this structure 650 * new fields can only be added to the end of this structure
594 */ 651 */
@@ -670,4 +727,75 @@ struct xdp_md {
670 __u32 data_end; 727 __u32 data_end;
671}; 728};
672 729
730#define BPF_TAG_SIZE 8
731
732struct bpf_prog_info {
733 __u32 type;
734 __u32 id;
735 __u8 tag[BPF_TAG_SIZE];
736 __u32 jited_prog_len;
737 __u32 xlated_prog_len;
738 __aligned_u64 jited_prog_insns;
739 __aligned_u64 xlated_prog_insns;
740} __attribute__((aligned(8)));
741
742struct bpf_map_info {
743 __u32 type;
744 __u32 id;
745 __u32 key_size;
746 __u32 value_size;
747 __u32 max_entries;
748 __u32 map_flags;
749} __attribute__((aligned(8)));
750
751/* User bpf_sock_ops struct to access socket values and specify request ops
752 * and their replies.
753 * New fields can only be added at the end of this structure
754 */
755struct bpf_sock_ops {
756 __u32 op;
757 union {
758 __u32 reply;
759 __u32 replylong[4];
760 };
761 __u32 family;
762 __u32 remote_ip4;
763 __u32 local_ip4;
764 __u32 remote_ip6[4];
765 __u32 local_ip6[4];
766 __u32 remote_port;
767 __u32 local_port;
768};
769
770/* List of known BPF sock_ops operators.
771 * New entries can only be added at the end
772 */
773enum {
774 BPF_SOCK_OPS_VOID,
775 BPF_SOCK_OPS_TIMEOUT_INIT, /* Should return SYN-RTO value to use or
776 * -1 if default value should be used
777 */
778 BPF_SOCK_OPS_RWND_INIT, /* Should return initial advertized
779 * window (in packets) or -1 if default
780 * value should be used
781 */
782 BPF_SOCK_OPS_TCP_CONNECT_CB, /* Calls BPF program right before an
783 * active connection is initialized
784 */
785 BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB, /* Calls BPF program when an
786 * active connection is
787 * established
788 */
789 BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB, /* Calls BPF program when a
790 * passive connection is
791 * established
792 */
793 BPF_SOCK_OPS_NEEDS_ECN, /* If connection's congestion control
794 * needs ECN
795 */
796};
797
798#define TCP_BPF_IW 1001 /* Set TCP initial congestion window */
799#define TCP_BPF_SNDCWND_CLAMP 1002 /* Set sndcwnd_clamp */
800
673#endif /* _UAPI__LINUX_BPF_H__ */ 801#endif /* _UAPI__LINUX_BPF_H__ */