github.com/metacubex/gvisor@v0.0.0-20240320004321-933faba989ec/pkg/abi/nvgpu/nvgpu.go (about)

     1  // Copyright 2023 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package nvgpu tracks the ABI of the Nvidia GPU Linux kernel driver:
    16  // https://github.com/NVIDIA/open-gpu-kernel-modules
    17  package nvgpu
    18  
    19  // Device numbers.
    20  const (
    21  	NV_MAJOR_DEVICE_NUMBER          = 195 // from kernel-open/common/inc/nv.h
    22  	NV_CONTROL_DEVICE_MINOR         = 255 // from kernel-open/common/inc/nv-linux.h
    23  	NVIDIA_UVM_PRIMARY_MINOR_NUMBER = 0   // from kernel-open/nvidia-uvm/uvm_common.h
    24  )
    25  
    26  // Handle is NvHandle, from src/common/sdk/nvidia/inc/nvtypes.h.
    27  //
    28  // +marshal
    29  type Handle struct {
    30  	Val uint32
    31  }
    32  
    33  // P64 is NvP64, from src/common/sdk/nvidia/inc/nvtypes.h.
    34  //
    35  // +marshal
    36  type P64 uint64
    37  
    38  // From src/common/sdk/nvidia/inc/nvlimits.h:
    39  const (
    40  	NV_MAX_DEVICES    = 32
    41  	NV_MAX_SUBDEVICES = 8
    42  )
    43  
    44  // From src/common/sdk/nvidia/inc/alloc/alloc_channel.h.
    45  const (
    46  	CC_CHAN_ALLOC_IV_SIZE_DWORD    = 3
    47  	CC_CHAN_ALLOC_NONCE_SIZE_DWORD = 8
    48  )
    49  
    50  // RS_ACCESS_MASK is RS_ACCESS_MASK, from
    51  // src/common/sdk/nvidia/inc/rs_access.h.
    52  //
    53  // +marshal
    54  type RS_ACCESS_MASK struct {
    55  	Limbs [SDK_RS_ACCESS_MAX_LIMBS]uint32 // RsAccessLimb
    56  }
    57  
    58  const SDK_RS_ACCESS_MAX_LIMBS = 1
    59  
    60  // RS_SHARE_POLICY is RS_SHARE_POLICY, from
    61  // src/common/sdk/nvidia/inc/rs_access.h.
    62  //
    63  // +marshal
    64  type RS_SHARE_POLICY struct {
    65  	Target     uint32
    66  	AccessMask RS_ACCESS_MASK
    67  	Type       uint16
    68  	Action     uint8
    69  	Pad        [1]byte
    70  }