Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[linux-2.6-block.git] / tools / include / uapi / linux / bpf.h
index 489e118b69d2cc2f4e73180c058fd6a29ef71960..f506c68b26127cd5b6c54f2b04106e2f7368f2ee 100644 (file)
@@ -170,6 +170,7 @@ enum bpf_prog_type {
        BPF_PROG_TYPE_FLOW_DISSECTOR,
        BPF_PROG_TYPE_CGROUP_SYSCTL,
        BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE,
+       BPF_PROG_TYPE_CGROUP_SOCKOPT,
 };
 
 enum bpf_attach_type {
@@ -194,6 +195,8 @@ enum bpf_attach_type {
        BPF_CGROUP_SYSCTL,
        BPF_CGROUP_UDP4_RECVMSG,
        BPF_CGROUP_UDP6_RECVMSG,
+       BPF_CGROUP_GETSOCKOPT,
+       BPF_CGROUP_SETSOCKOPT,
        __MAX_BPF_ATTACH_TYPE
 };
 
@@ -262,6 +265,24 @@ enum bpf_attach_type {
  */
 #define BPF_F_ANY_ALIGNMENT    (1U << 1)
 
+/* BPF_F_TEST_RND_HI32 is used in BPF_PROG_LOAD command for testing purpose.
+ * Verifier does sub-register def/use analysis and identifies instructions whose
+ * def only matters for low 32-bit, high 32-bit is never referenced later
+ * through implicit zero extension. Therefore verifier notifies JIT back-ends
+ * that it is safe to ignore clearing high 32-bit for these instructions. This
+ * saves some back-ends a lot of code-gen. However such optimization is not
+ * necessary on some arches, for example x86_64, arm64 etc, whose JIT back-ends
+ * hence hasn't used verifier's analysis result. But, we really want to have a
+ * way to be able to verify the correctness of the described optimization on
+ * x86_64 on which testsuites are frequently exercised.
+ *
+ * So, this flag is introduced. Once it is set, verifier will randomize high
+ * 32-bit for those instructions who has been identified as safe to ignore them.
+ * Then, if verifier is not doing correct analysis, such randomization will
+ * regress tests to expose bugs.
+ */
+#define BPF_F_TEST_RND_HI32    (1U << 2)
+
 /* When BPF ldimm64's insn[0].src_reg != 0 then this can have
  * two extensions:
  *
@@ -1746,6 +1767,7 @@ union bpf_attr {
  *             * **BPF_SOCK_OPS_RTO_CB_FLAG** (retransmission time out)
  *             * **BPF_SOCK_OPS_RETRANS_CB_FLAG** (retransmission)
  *             * **BPF_SOCK_OPS_STATE_CB_FLAG** (TCP state change)
+ *             * **BPF_SOCK_OPS_RTT_CB_FLAG** (every RTT)
  *
  *             Therefore, this function can be used to clear a callback flag by
  *             setting the appropriate bit to zero. e.g. to disable the RTO
@@ -2674,6 +2696,20 @@ union bpf_attr {
  *             0 on success.
  *
  *             **-ENOENT** if the bpf-local-storage cannot be found.
+ *
+ * int bpf_send_signal(u32 sig)
+ *     Description
+ *             Send signal *sig* to the current task.
+ *     Return
+ *             0 on success or successfully queued.
+ *
+ *             **-EBUSY** if work queue under nmi is full.
+ *
+ *             **-EINVAL** if *sig* is invalid.
+ *
+ *             **-EPERM** if no permission to send the *sig*.
+ *
+ *             **-EAGAIN** if bpf program can try again.
  */
 #define __BPF_FUNC_MAPPER(FN)          \
        FN(unspec),                     \
@@ -2784,7 +2820,8 @@ union bpf_attr {
        FN(strtol),                     \
        FN(strtoul),                    \
        FN(sk_storage_get),             \
-       FN(sk_storage_delete),
+       FN(sk_storage_delete),          \
+       FN(send_signal),
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
  * function eBPF program intends to call
@@ -3033,6 +3070,12 @@ struct bpf_tcp_sock {
                                 * sum(delta(snd_una)), or how many bytes
                                 * were acked.
                                 */
+       __u32 dsack_dups;       /* RFC4898 tcpEStatsStackDSACKDups
+                                * total number of DSACK blocks received
+                                */
+       __u32 delivered;        /* Total data packets delivered incl. rexmits */
+       __u32 delivered_ce;     /* Like the above but only ECE marked packets */
+       __u32 icsk_retransmits; /* Number of unrecovered [RTO] timeouts */
 };
 
 struct bpf_sock_tuple {
@@ -3052,6 +3095,10 @@ struct bpf_sock_tuple {
        };
 };
 
+struct bpf_xdp_sock {
+       __u32 queue_id;
+};
+
 #define XDP_PACKET_HEADROOM 256
 
 /* User return codes for XDP prog type.
@@ -3143,6 +3190,7 @@ struct bpf_prog_info {
        char name[BPF_OBJ_NAME_LEN];
        __u32 ifindex;
        __u32 gpl_compatible:1;
+       __u32 :31; /* alignment pad */
        __u64 netns_dev;
        __u64 netns_ino;
        __u32 nr_jited_ksyms;
@@ -3197,7 +3245,7 @@ struct bpf_sock_addr {
        __u32 user_ip4;         /* Allows 1,2,4-byte read and 4-byte write.
                                 * Stored in network byte order.
                                 */
-       __u32 user_ip6[4];      /* Allows 1,2,4-byte read an 4-byte write.
+       __u32 user_ip6[4];      /* Allows 1,2,4-byte read and 4,8-byte write.
                                 * Stored in network byte order.
                                 */
        __u32 user_port;        /* Allows 4-byte read and write.
@@ -3206,12 +3254,13 @@ struct bpf_sock_addr {
        __u32 family;           /* Allows 4-byte read, but no write */
        __u32 type;             /* Allows 4-byte read, but no write */
        __u32 protocol;         /* Allows 4-byte read, but no write */
-       __u32 msg_src_ip4;      /* Allows 1,2,4-byte read an 4-byte write.
+       __u32 msg_src_ip4;      /* Allows 1,2,4-byte read and 4-byte write.
                                 * Stored in network byte order.
                                 */
-       __u32 msg_src_ip6[4];   /* Allows 1,2,4-byte read an 4-byte write.
+       __u32 msg_src_ip6[4];   /* Allows 1,2,4-byte read and 4,8-byte write.
                                 * Stored in network byte order.
                                 */
+       __bpf_md_ptr(struct bpf_sock *, sk);
 };
 
 /* User bpf_sock_ops struct to access socket values and specify request ops
@@ -3263,13 +3312,15 @@ struct bpf_sock_ops {
        __u32 sk_txhash;
        __u64 bytes_received;
        __u64 bytes_acked;
+       __bpf_md_ptr(struct bpf_sock *, sk);
 };
 
 /* Definitions for bpf_sock_ops_cb_flags */
 #define BPF_SOCK_OPS_RTO_CB_FLAG       (1<<0)
 #define BPF_SOCK_OPS_RETRANS_CB_FLAG   (1<<1)
 #define BPF_SOCK_OPS_STATE_CB_FLAG     (1<<2)
-#define BPF_SOCK_OPS_ALL_CB_FLAGS       0x7            /* Mask of all currently
+#define BPF_SOCK_OPS_RTT_CB_FLAG       (1<<3)
+#define BPF_SOCK_OPS_ALL_CB_FLAGS       0xF            /* Mask of all currently
                                                         * supported cb flags
                                                         */
 
@@ -3324,6 +3375,8 @@ enum {
        BPF_SOCK_OPS_TCP_LISTEN_CB,     /* Called on listen(2), right after
                                         * socket transition to LISTEN state.
                                         */
+       BPF_SOCK_OPS_RTT_CB,            /* Called on every RTT.
+                                        */
 };
 
 /* List of TCP states. There is a build check in net/ipv4/tcp.c to detect
@@ -3502,4 +3555,15 @@ struct bpf_sysctl {
                                 */
 };
 
+struct bpf_sockopt {
+       __bpf_md_ptr(struct bpf_sock *, sk);
+       __bpf_md_ptr(void *, optval);
+       __bpf_md_ptr(void *, optval_end);
+
+       __s32   level;
+       __s32   optname;
+       __s32   optlen;
+       __s32   retval;
+};
+
 #endif /* _UAPI__LINUX_BPF_H__ */