1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (C) 2021. Huawei Technologies Co., Ltd */
3#include "vmlinux.h"
4#include <bpf/bpf_helpers.h>
5#include <bpf/bpf_tracing.h>
6
7char _license[] SEC("license") = "GPL";
8
9SEC("struct_ops/test_1")
10int BPF_PROG(test_1, struct bpf_dummy_ops_state *state)
11{
12	int ret;
13
14	if (!state)
15		return 0xf2f3f4f5;
16
17	ret = state->val;
18	state->val = 0x5a;
19	return ret;
20}
21
22__u64 test_2_args[5];
23
24SEC("struct_ops/test_2")
25int BPF_PROG(test_2, struct bpf_dummy_ops_state *state, int a1, unsigned short a2,
26	     char a3, unsigned long a4)
27{
28	test_2_args[0] = (unsigned long)state;
29	test_2_args[1] = a1;
30	test_2_args[2] = a2;
31	test_2_args[3] = a3;
32	test_2_args[4] = a4;
33	return 0;
34}
35
36SEC("struct_ops.s/test_sleepable")
37int BPF_PROG(test_sleepable, struct bpf_dummy_ops_state *state)
38{
39	return 0;
40}
41
42SEC(".struct_ops")
43struct bpf_dummy_ops dummy_1 = {
44	.test_1 = (void *)test_1,
45	.test_2 = (void *)test_2,
46	.test_sleepable = (void *)test_sleepable,
47};
48