// Code generated by bpf2go; DO NOT EDIT.
//go:build arm64

package binary

import (
	"bytes"
	_ "embed"
	"fmt"
	"io"

	"github.com/cilium/ebpf"
)

type NFSTraceDataArgsT struct {
	SourceFn   uint32
	Fd         uint32
	Buf        uint64
	Iov        uint64
	Sk         uint64
	Iovlen     uint64
	MsgLen     uint64
	SocketId   uint64
	TcpSeq     uint32
	BytesCount int64
	Port       uint16
	Addr       [16]uint8
}

type NFSTraceDnsArgsT struct {
	IovBase   uint64
	IovLen    uint32
	Direction uint32
}

type NFSTraceDnsEvent struct {
	Pid    uint32
	Len    uint32
	Common [100]int8
	Domain [200]int8
}

type NFSTraceMemberFieldsOffset struct {
	Ready                          uint32
	TaskFilesOffset                uint32
	SockFlagsOffset                uint32
	TcpSockCopiedSeqOffset         uint32
	TcpSockWriteSeqOffset          uint32
	StructFilesStructFdtOffset     uint32
	StructFilesPrivateDataOffset   uint32
	StructFileF_inodeOffset        uint32
	StructInodeI_modeOffset        uint32
	StructFileDentryOffset         uint32
	StructDentryNameOffset         uint32
	StructSockFamilyOffset         uint32
	StructSockSaddrOffset          uint32
	StructSockDaddrOffset          uint32
	StructSockIp6saddrOffset       uint32
	StructSockIp6daddrOffset       uint32
	StructSockDportOffset          uint32
	StructSockSportOffset          uint32
	StructSockSkcStateOffset       uint32
	StructSockCommonIpv6onlyOffset uint32
	StructIovIterIovOffset         uint32
}

type NFSTraceMetadata struct {
	Pod       [100]int8
	Container [100]int8
	Pid       uint64
}

type NFSTracePathSegment struct {
	FileId     uint64
	DevId      uint64
	Len        uint32
	IsComplete uint8
	Depth      uint8
	Name       [100]uint8
	_          [6]byte
}

type NFSTraceRawMetrics struct {
	ReadCount  uint64
	ReadSize   uint64
	ReadLat    uint64
	WriteCount uint64
	WriteSize  uint64
	WriteLat   uint64
	Pod        [100]int8
	Container  [100]int8
}

type NFSTraceRpcTaskFields struct {
	Pid        int32
	MountId    int32
	Pod        [100]int8
	Container  [100]int8
	CallerAddr uint64
	DevId      uint32
	FileId     uint32
	Key        uint64
}

type NFSTraceSchedLatencyT struct {
	Pid           uint32
	Tid           uint32
	DelayNs       uint64
	Ts            uint64
	PreemptedPid  uint32
	PreemptedComm [16]int8
	IsPreempt     uint64
	Comm          [16]int8
}

type NFSTraceSpanInfo struct {
	Timestamp    uint64
	StartTime    uint64
	EndTime      uint64
	TraceId      uint64
	SpanId       uint64
	ParentSpanId uint64
	Pid          uint32
	Tid          uint32
	Name         [32]int8
	Pod          [100]int8
	Container    [100]int8
	DevFileId    uint64
}

type NFSTraceStackSample struct {
	RequestId     uint64
	Timestamp     uint64
	Pid           uint32
	Cpu           uint32
	KernelStackId int64
	UserStackId   int64
}

// LoadNFSTrace returns the embedded CollectionSpec for NFSTrace.
func LoadNFSTrace() (*ebpf.CollectionSpec, error) {
	reader := bytes.NewReader(_NFSTraceBytes)
	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("can't load NFSTrace: %w", err)
	}

	return spec, err
}

// LoadNFSTraceObjects loads NFSTrace and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*NFSTraceObjects
//	*NFSTracePrograms
//	*NFSTraceMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func LoadNFSTraceObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := LoadNFSTrace()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// NFSTraceSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type NFSTraceSpecs struct {
	NFSTraceProgramSpecs
	NFSTraceMapSpecs
}

// NFSTraceSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type NFSTraceProgramSpecs struct {
	DnsHandler          *ebpf.ProgramSpec `ebpf:"dns_handler"`
	DoPerfEvent         *ebpf.ProgramSpec `ebpf:"do_perf_event"`
	FexitFn             *ebpf.ProgramSpec `ebpf:"fexit_fn"`
	KbNfsReadD          *ebpf.ProgramSpec `ebpf:"kb_nfs_read_d"`
	KbNfsWriteD         *ebpf.ProgramSpec `ebpf:"kb_nfs_write_d"`
	KprobeSkb1          *ebpf.ProgramSpec `ebpf:"kprobe_skb_1"`
	KprobeSkb2          *ebpf.ProgramSpec `ebpf:"kprobe_skb_2"`
	KprobeSkb3          *ebpf.ProgramSpec `ebpf:"kprobe_skb_3"`
	KprobeSkb4          *ebpf.ProgramSpec `ebpf:"kprobe_skb_4"`
	KprobeSkb5          *ebpf.ProgramSpec `ebpf:"kprobe_skb_5"`
	KprobeSysRecvmsg    *ebpf.ProgramSpec `ebpf:"kprobe_sys_recvmsg"`
	KprobeSysSendmsg    *ebpf.ProgramSpec `ebpf:"kprobe_sys_sendmsg"`
	KprobeUdpSendmsg    *ebpf.ProgramSpec `ebpf:"kprobe_udp_sendmsg"`
	KretprobeSysRecvmsg *ebpf.ProgramSpec `ebpf:"kretprobe_sys_recvmsg"`
	KretprobeSysSendmsg *ebpf.ProgramSpec `ebpf:"kretprobe_sys_sendmsg"`
	NfsInitRead         *ebpf.ProgramSpec `ebpf:"nfs_init_read"`
	NfsInitWrite        *ebpf.ProgramSpec `ebpf:"nfs_init_write"`
	RpcExecute          *ebpf.ProgramSpec `ebpf:"rpc_execute"`
	RpcExitTask         *ebpf.ProgramSpec `ebpf:"rpc_exit_task"`
	RpcTaskBegin        *ebpf.ProgramSpec `ebpf:"rpc_task_begin"`
	RpcTaskDone         *ebpf.ProgramSpec `ebpf:"rpc_task_done"`
	SchedSwitch         *ebpf.ProgramSpec `ebpf:"sched_switch"`
	SchedWakeup         *ebpf.ProgramSpec `ebpf:"sched_wakeup"`
	SchedWakeupNew      *ebpf.ProgramSpec `ebpf:"sched_wakeup_new"`
}

// NFSTraceMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type NFSTraceMapSpecs struct {
	ActiveReadArgsMap  *ebpf.MapSpec `ebpf:"__active_read_args_map"`
	ActiveWriteArgsMap *ebpf.MapSpec `ebpf:"__active_write_args_map"`
	DnsArgsMap         *ebpf.MapSpec `ebpf:"__dns_args_map"`
	MembersOffset      *ebpf.MapSpec `ebpf:"__members_offset"`
	NfsSpanMap         *ebpf.MapSpec `ebpf:"__nfs_span_map"`
	ActiveRequests     *ebpf.MapSpec `ebpf:"active_requests"`
	CpuProfilerEvents  *ebpf.MapSpec `ebpf:"cpu_profiler_events"`
	DnsEvents          *ebpf.MapSpec `ebpf:"dns_events"`
	DnsProgArray       *ebpf.MapSpec `ebpf:"dns_prog_array"`
	IoMetrics          *ebpf.MapSpec `ebpf:"io_metrics"`
	LastSample         *ebpf.MapSpec `ebpf:"last_sample"`
	LinkBegin          *ebpf.MapSpec `ebpf:"link_begin"`
	LinkEnd            *ebpf.MapSpec `ebpf:"link_end"`
	NfsTraceMap        *ebpf.MapSpec `ebpf:"nfs_trace_map"`
	PathRingbuf        *ebpf.MapSpec `ebpf:"path_ringbuf"`
	PidCgroupMap       *ebpf.MapSpec `ebpf:"pid_cgroup_map"`
	ProfilerEvents     *ebpf.MapSpec `ebpf:"profiler_events"`
	SchedEvents        *ebpf.MapSpec `ebpf:"sched_events"`
	StackTraces        *ebpf.MapSpec `ebpf:"stack_traces"`
	WaitingRPC         *ebpf.MapSpec `ebpf:"waiting_RPC"`
	WakeupTimes        *ebpf.MapSpec `ebpf:"wakeup_times"`
}

// NFSTraceObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to LoadNFSTraceObjects or ebpf.CollectionSpec.LoadAndAssign.
type NFSTraceObjects struct {
	NFSTracePrograms
	NFSTraceMaps
}

func (o *NFSTraceObjects) Close() error {
	return _NFSTraceClose(
		&o.NFSTracePrograms,
		&o.NFSTraceMaps,
	)
}

// NFSTraceMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to LoadNFSTraceObjects or ebpf.CollectionSpec.LoadAndAssign.
type NFSTraceMaps struct {
	ActiveReadArgsMap  *ebpf.Map `ebpf:"__active_read_args_map"`
	ActiveWriteArgsMap *ebpf.Map `ebpf:"__active_write_args_map"`
	DnsArgsMap         *ebpf.Map `ebpf:"__dns_args_map"`
	MembersOffset      *ebpf.Map `ebpf:"__members_offset"`
	NfsSpanMap         *ebpf.Map `ebpf:"__nfs_span_map"`
	ActiveRequests     *ebpf.Map `ebpf:"active_requests"`
	CpuProfilerEvents  *ebpf.Map `ebpf:"cpu_profiler_events"`
	DnsEvents          *ebpf.Map `ebpf:"dns_events"`
	DnsProgArray       *ebpf.Map `ebpf:"dns_prog_array"`
	IoMetrics          *ebpf.Map `ebpf:"io_metrics"`
	LastSample         *ebpf.Map `ebpf:"last_sample"`
	LinkBegin          *ebpf.Map `ebpf:"link_begin"`
	LinkEnd            *ebpf.Map `ebpf:"link_end"`
	NfsTraceMap        *ebpf.Map `ebpf:"nfs_trace_map"`
	PathRingbuf        *ebpf.Map `ebpf:"path_ringbuf"`
	PidCgroupMap       *ebpf.Map `ebpf:"pid_cgroup_map"`
	ProfilerEvents     *ebpf.Map `ebpf:"profiler_events"`
	SchedEvents        *ebpf.Map `ebpf:"sched_events"`
	StackTraces        *ebpf.Map `ebpf:"stack_traces"`
	WaitingRPC         *ebpf.Map `ebpf:"waiting_RPC"`
	WakeupTimes        *ebpf.Map `ebpf:"wakeup_times"`
}

func (m *NFSTraceMaps) Close() error {
	return _NFSTraceClose(
		m.ActiveReadArgsMap,
		m.ActiveWriteArgsMap,
		m.DnsArgsMap,
		m.MembersOffset,
		m.NfsSpanMap,
		m.ActiveRequests,
		m.CpuProfilerEvents,
		m.DnsEvents,
		m.DnsProgArray,
		m.IoMetrics,
		m.LastSample,
		m.LinkBegin,
		m.LinkEnd,
		m.NfsTraceMap,
		m.PathRingbuf,
		m.PidCgroupMap,
		m.ProfilerEvents,
		m.SchedEvents,
		m.StackTraces,
		m.WaitingRPC,
		m.WakeupTimes,
	)
}

// NFSTracePrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to LoadNFSTraceObjects or ebpf.CollectionSpec.LoadAndAssign.
type NFSTracePrograms struct {
	DnsHandler          *ebpf.Program `ebpf:"dns_handler"`
	DoPerfEvent         *ebpf.Program `ebpf:"do_perf_event"`
	FexitFn             *ebpf.Program `ebpf:"fexit_fn"`
	KbNfsReadD          *ebpf.Program `ebpf:"kb_nfs_read_d"`
	KbNfsWriteD         *ebpf.Program `ebpf:"kb_nfs_write_d"`
	KprobeSkb1          *ebpf.Program `ebpf:"kprobe_skb_1"`
	KprobeSkb2          *ebpf.Program `ebpf:"kprobe_skb_2"`
	KprobeSkb3          *ebpf.Program `ebpf:"kprobe_skb_3"`
	KprobeSkb4          *ebpf.Program `ebpf:"kprobe_skb_4"`
	KprobeSkb5          *ebpf.Program `ebpf:"kprobe_skb_5"`
	KprobeSysRecvmsg    *ebpf.Program `ebpf:"kprobe_sys_recvmsg"`
	KprobeSysSendmsg    *ebpf.Program `ebpf:"kprobe_sys_sendmsg"`
	KprobeUdpSendmsg    *ebpf.Program `ebpf:"kprobe_udp_sendmsg"`
	KretprobeSysRecvmsg *ebpf.Program `ebpf:"kretprobe_sys_recvmsg"`
	KretprobeSysSendmsg *ebpf.Program `ebpf:"kretprobe_sys_sendmsg"`
	NfsInitRead         *ebpf.Program `ebpf:"nfs_init_read"`
	NfsInitWrite        *ebpf.Program `ebpf:"nfs_init_write"`
	RpcExecute          *ebpf.Program `ebpf:"rpc_execute"`
	RpcExitTask         *ebpf.Program `ebpf:"rpc_exit_task"`
	RpcTaskBegin        *ebpf.Program `ebpf:"rpc_task_begin"`
	RpcTaskDone         *ebpf.Program `ebpf:"rpc_task_done"`
	SchedSwitch         *ebpf.Program `ebpf:"sched_switch"`
	SchedWakeup         *ebpf.Program `ebpf:"sched_wakeup"`
	SchedWakeupNew      *ebpf.Program `ebpf:"sched_wakeup_new"`
}

func (p *NFSTracePrograms) Close() error {
	return _NFSTraceClose(
		p.DnsHandler,
		p.DoPerfEvent,
		p.FexitFn,
		p.KbNfsReadD,
		p.KbNfsWriteD,
		p.KprobeSkb1,
		p.KprobeSkb2,
		p.KprobeSkb3,
		p.KprobeSkb4,
		p.KprobeSkb5,
		p.KprobeSysRecvmsg,
		p.KprobeSysSendmsg,
		p.KprobeUdpSendmsg,
		p.KretprobeSysRecvmsg,
		p.KretprobeSysSendmsg,
		p.NfsInitRead,
		p.NfsInitWrite,
		p.RpcExecute,
		p.RpcExitTask,
		p.RpcTaskBegin,
		p.RpcTaskDone,
		p.SchedSwitch,
		p.SchedWakeup,
		p.SchedWakeupNew,
	)
}

func _NFSTraceClose(closers ...io.Closer) error {
	for _, closer := range closers {
		if err := closer.Close(); err != nil {
			return err
		}
	}
	return nil
}

// Do not access this directly.
//
//go:embed nfstrace_arm64_bpfel.o
var _NFSTraceBytes []byte
