162306a36Sopenharmony_ci#ifndef __BPF_KFUNCS__
262306a36Sopenharmony_ci#define __BPF_KFUNCS__
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci/* Description
562306a36Sopenharmony_ci *  Initializes an skb-type dynptr
662306a36Sopenharmony_ci * Returns
762306a36Sopenharmony_ci *  Error code
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ciextern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
1062306a36Sopenharmony_ci    struct bpf_dynptr *ptr__uninit) __ksym;
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci/* Description
1362306a36Sopenharmony_ci *  Initializes an xdp-type dynptr
1462306a36Sopenharmony_ci * Returns
1562306a36Sopenharmony_ci *  Error code
1662306a36Sopenharmony_ci */
1762306a36Sopenharmony_ciextern int bpf_dynptr_from_xdp(struct xdp_md *xdp, __u64 flags,
1862306a36Sopenharmony_ci			       struct bpf_dynptr *ptr__uninit) __ksym;
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* Description
2162306a36Sopenharmony_ci *  Obtain a read-only pointer to the dynptr's data
2262306a36Sopenharmony_ci * Returns
2362306a36Sopenharmony_ci *  Either a direct pointer to the dynptr data or a pointer to the user-provided
2462306a36Sopenharmony_ci *  buffer if unable to obtain a direct pointer
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_ciextern void *bpf_dynptr_slice(const struct bpf_dynptr *ptr, __u32 offset,
2762306a36Sopenharmony_ci			      void *buffer, __u32 buffer__szk) __ksym;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* Description
3062306a36Sopenharmony_ci *  Obtain a read-write pointer to the dynptr's data
3162306a36Sopenharmony_ci * Returns
3262306a36Sopenharmony_ci *  Either a direct pointer to the dynptr data or a pointer to the user-provided
3362306a36Sopenharmony_ci *  buffer if unable to obtain a direct pointer
3462306a36Sopenharmony_ci */
3562306a36Sopenharmony_ciextern void *bpf_dynptr_slice_rdwr(const struct bpf_dynptr *ptr, __u32 offset,
3662306a36Sopenharmony_ci			      void *buffer, __u32 buffer__szk) __ksym;
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciextern int bpf_dynptr_adjust(const struct bpf_dynptr *ptr, __u32 start, __u32 end) __ksym;
3962306a36Sopenharmony_ciextern bool bpf_dynptr_is_null(const struct bpf_dynptr *ptr) __ksym;
4062306a36Sopenharmony_ciextern bool bpf_dynptr_is_rdonly(const struct bpf_dynptr *ptr) __ksym;
4162306a36Sopenharmony_ciextern __u32 bpf_dynptr_size(const struct bpf_dynptr *ptr) __ksym;
4262306a36Sopenharmony_ciextern int bpf_dynptr_clone(const struct bpf_dynptr *ptr, struct bpf_dynptr *clone__init) __ksym;
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#endif
45