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

package maps

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

	"github.com/cilium/ebpf"
)

type gputypesGpuDeviceMetrics struct {
	_                   structs.HostLayout
	TimestampNs         uint64
	SmUtilPct           uint32
	MemUtilPct          uint32
	MemTotal            uint64
	MemUsed             uint64
	MemReserved         uint64
	TempC               uint32
	PowerMw             uint32
	SmClockMhz          uint32
	MemClockMhz         uint32
	ThrottleReasons     uint64
	PcieTxKbps          uint64
	PcieRxKbps          uint64
	EncUtilPct          uint32
	DecUtilPct          uint32
	NvlinkTxKbps        uint64
	NvlinkRxKbps        uint64
	EccCorrectedTotal   uint64
	EccUncorrectedTotal uint64
	FanSpeedPct         uint32
	ComputeMode         uint32
}

type gputypesGpuMeta struct {
	_                    structs.HostLayout
	SchemaVersion        uint32
	N_devices            uint32
	LastUpdateBoottimeNs uint64
	HelperPid            uint32
	Reserved             uint32
	ClockOffsetNs        int64
}

type gputypesGpuPidMetrics struct {
	_             structs.HostLayout
	TimestampNs   uint64
	UsedGpuMemory uint64
	SmUtilPct     uint32
	MemUtilPct    uint32
	EncUtilPct    uint32
	DecUtilPct    uint32
	GpuDevice     uint8
	MigInstance   uint8
	Pad           uint16
	_             [4]byte
}

type gputypesGpuPidMetricsAggregated struct {
	_                  structs.HostLayout
	TimestampNs        uint64
	UsedGpuMemoryTotal uint64
	SmUtilPctMax       uint32
	MemUtilPctMax      uint32
	GpuDevicePrimary   uint8
	DeviceCount        uint8
	Pad                uint16
	_                  [4]byte
}

// Names of all BPF objects in the ELF.
//
// Used for safe lookups in a Collection or CollectionSpec.
const (
	gputypesMapGpuDevice          = "gpu_device"
	gputypesMapGpuMeta            = "gpu_meta"
	gputypesMapGpuPerPid          = "gpu_per_pid"
	gputypesMapGpuPerPidPerDevice = "gpu_per_pid_per_device"
)

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

	return spec, err
}

// loadGputypesObjects loads gputypes and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*gputypesObjects
//	*gputypesPrograms
//	*gputypesMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadGputypesObjects(obj any, opts *ebpf.CollectionOptions) error {
	spec, err := loadGputypes()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// gputypesSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type gputypesSpecs struct {
	gputypesProgramSpecs
	gputypesMapSpecs
	gputypesVariableSpecs
}

// gputypesProgramSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type gputypesProgramSpecs struct {
}

// gputypesMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type gputypesMapSpecs struct {
	GpuDevice          *ebpf.MapSpec `ebpf:"gpu_device"`
	GpuMeta            *ebpf.MapSpec `ebpf:"gpu_meta"`
	GpuPerPid          *ebpf.MapSpec `ebpf:"gpu_per_pid"`
	GpuPerPidPerDevice *ebpf.MapSpec `ebpf:"gpu_per_pid_per_device"`
}

// gputypesVariableSpecs contains global variables before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type gputypesVariableSpecs struct {
}

// gputypesObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadGputypesObjects or ebpf.CollectionSpec.LoadAndAssign.
type gputypesObjects struct {
	gputypesPrograms
	gputypesMaps
	gputypesVariables
}

func (o *gputypesObjects) Close() error {
	return _GputypesClose(
		&o.gputypesPrograms,
		&o.gputypesMaps,
	)
}

// gputypesMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadGputypesObjects or ebpf.CollectionSpec.LoadAndAssign.
type gputypesMaps struct {
	GpuDevice          *ebpf.Map `ebpf:"gpu_device"`
	GpuMeta            *ebpf.Map `ebpf:"gpu_meta"`
	GpuPerPid          *ebpf.Map `ebpf:"gpu_per_pid"`
	GpuPerPidPerDevice *ebpf.Map `ebpf:"gpu_per_pid_per_device"`
}

func (m *gputypesMaps) Close() error {
	return _GputypesClose(
		m.GpuDevice,
		m.GpuMeta,
		m.GpuPerPid,
		m.GpuPerPidPerDevice,
	)
}

// gputypesVariables contains all global variables after they have been loaded into the kernel.
//
// It can be passed to loadGputypesObjects or ebpf.CollectionSpec.LoadAndAssign.
type gputypesVariables struct {
}

// gputypesPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadGputypesObjects or ebpf.CollectionSpec.LoadAndAssign.
type gputypesPrograms struct {
}

func (p *gputypesPrograms) Close() error {
	return _GputypesClose()
}

func _GputypesClose(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 gputypes_arm64_bpfel.o
var _GputypesBytes []byte
