1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
5 #include <bpf/bpf_helpers.h>
8 struct bpf_iter_testmod_seq {
13 extern int bpf_iter_testmod_seq_new(struct bpf_iter_testmod_seq *it, s64 value, int cnt) __ksym;
14 extern s64 *bpf_iter_testmod_seq_next(struct bpf_iter_testmod_seq *it) __ksym;
15 extern void bpf_iter_testmod_seq_destroy(struct bpf_iter_testmod_seq *it) __ksym;
17 const volatile __s64 exp_empty = 0 + 1;
20 SEC("raw_tp/sys_enter")
21 __success __log_level(2)
22 __msg("fp-16_w=iter_testmod_seq(ref_id=1,state=active,depth=0)")
23 __msg("fp-16=iter_testmod_seq(ref_id=1,state=drained,depth=0)")
24 __msg("call bpf_iter_testmod_seq_destroy")
25 int testmod_seq_empty(const void *ctx)
29 bpf_for_each(testmod_seq, i, 1000, 0) sum += *i;
35 const volatile __s64 exp_full = 1000000;
38 SEC("raw_tp/sys_enter")
39 __success __log_level(2)
40 __msg("fp-16_w=iter_testmod_seq(ref_id=1,state=active,depth=0)")
41 __msg("fp-16=iter_testmod_seq(ref_id=1,state=drained,depth=0)")
42 __msg("call bpf_iter_testmod_seq_destroy")
43 int testmod_seq_full(const void *ctx)
47 bpf_for_each(testmod_seq, i, 1000, 1000) sum += *i;
53 const volatile __s64 exp_truncated = 10 * 1000000;
56 static volatile int zero = 0;
58 SEC("raw_tp/sys_enter")
59 __success __log_level(2)
60 __msg("fp-16_w=iter_testmod_seq(ref_id=1,state=active,depth=0)")
61 __msg("fp-16=iter_testmod_seq(ref_id=1,state=drained,depth=0)")
62 __msg("call bpf_iter_testmod_seq_destroy")
63 int testmod_seq_truncated(const void *ctx)
68 bpf_for_each(testmod_seq, i, 10, 2000000) {
79 char _license[] SEC("license") = "GPL";