
#ifndef _G_SEC2_UTILS_NVOC_H_
#define _G_SEC2_UTILS_NVOC_H_

// Version of generated metadata structures
#ifdef NVOC_METADATA_VERSION
#undef NVOC_METADATA_VERSION
#endif
#define NVOC_METADATA_VERSION 2

#include "nvoc/runtime.h"
#include "nvoc/rtti.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
 * SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#pragma once
#include "g_sec2_utils_nvoc.h"

#ifndef SEC2_UTILS_H
#define SEC2_UTILS_H

#include "gpu/gpu_resource.h" // GpuResource

#include "kernel/gpu/mem_mgr/channel_utils.h"

#include "kernel/gpu/conf_compute/ccsl_context.h"

#define SEC2_AUTH_TAG_BUF_SIZE_BYTES (16)
#define SHA_256_HASH_SIZE_BYTES (32)

typedef struct
{
    MEMORY_DESCRIPTOR *pMemDesc;
    NvU64 offset;
    NvU64 length;
    NvU64 submittedWorkId; 
} SEC2UTILS_MEMSET_PARAMS;

typedef struct
{
    NvHandle hPhysMem;
    NvHandle hVirtMem;
    NvHandle hVASpace;
    NvU64    gpuVA;
    NvU64    size;
    MEMORY_DESCRIPTOR *pMemDesc;
} SEC2UTILS_BUFFER_INFO;


// Private field names are wrapped in PRIVATE_FIELD, which does nothing for
// the matching C source file, but causes diagnostics to be issued if another
// source file references the field.
#ifdef NVOC_SEC2_UTILS_H_PRIVATE_ACCESS_ALLOWED
#define PRIVATE_FIELD(x) x
#else
#define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
#endif


// Metadata with per-class RTTI with ancestor(s)
struct NVOC_METADATA__Sec2Utils;
struct NVOC_METADATA__Object;


struct Sec2Utils {

    // Metadata starts with RTTI structure.
    union {
         const struct NVOC_METADATA__Sec2Utils *__nvoc_metadata_ptr;
         const struct NVOC_RTTI *__nvoc_rtti;
    };

    // Parent (i.e. superclass or base class) objects
    struct Object __nvoc_base_Object;

    // Ancestor object pointers for `staticCast` feature
    struct Object *__nvoc_pbase_Object;    // obj super
    struct Sec2Utils *__nvoc_pbase_Sec2Utils;    // sec2utils

    // Data members
    NvHandle hClient;
    NvHandle hDevice;
    NvHandle hSubdevice;
    OBJCHANNEL *pChannel;
    struct OBJGPU *pGpu;
    NvU32 sec2Class;
    NvU64 lastSubmittedPayload;
    NvU64 lastCompletedPayload;
    CCSL_CONTEXT *pCcslCtx;
    SEC2UTILS_BUFFER_INFO scrubMthdAuthTagBuf;
    SEC2UTILS_BUFFER_INFO semaMthdAuthTagBuf;
    NvU32 authTagPutIndex;
    NvU32 authTagGetIndex;
};


// Metadata with per-class RTTI with ancestor(s)
struct NVOC_METADATA__Sec2Utils {
    const struct NVOC_RTTI rtti;
    const struct NVOC_METADATA__Object metadata__Object;
};

#ifndef __nvoc_class_id_Sec2Utils
#define __nvoc_class_id_Sec2Utils 0x7716b1u
typedef struct Sec2Utils Sec2Utils;
#endif /* __nvoc_class_id_Sec2Utils */

// Casting support
extern const struct NVOC_CLASS_DEF __nvoc_class_def_Sec2Utils;

#define __staticCast_Sec2Utils(pThis) \
    ((pThis)->__nvoc_pbase_Sec2Utils)

#ifdef __nvoc_sec2_utils_h_disabled
#define __dynamicCast_Sec2Utils(pThis) ((Sec2Utils*) NULL)
#else //__nvoc_sec2_utils_h_disabled
#define __dynamicCast_Sec2Utils(pThis) \
    ((Sec2Utils*) __nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(Sec2Utils)))
#endif //__nvoc_sec2_utils_h_disabled

NV_STATUS __nvoc_objCreateDynamic_Sec2Utils(Sec2Utils**, Dynamic*, NvU32, va_list);

NV_STATUS __nvoc_objCreate_Sec2Utils(Sec2Utils**, Dynamic*, NvU32, struct OBJGPU *pGpu, KERNEL_MIG_GPU_INSTANCE *pKernelMIGGPUInstance);
#define __objCreate_Sec2Utils(__nvoc_ppNewObj, __nvoc_pParent, __nvoc_createFlags, pGpu, pKernelMIGGPUInstance) \
    __nvoc_objCreate_Sec2Utils((__nvoc_ppNewObj), staticCast((__nvoc_pParent), Dynamic), (__nvoc_createFlags), pGpu, pKernelMIGGPUInstance)


// Wrapper macros for implementation functions
NV_STATUS sec2utilsConstruct_IMPL(struct Sec2Utils *psec2utils, struct OBJGPU *pGpu, KERNEL_MIG_GPU_INSTANCE *pKernelMIGGPUInstance);
#define __nvoc_sec2utilsConstruct(psec2utils, pGpu, pKernelMIGGPUInstance) sec2utilsConstruct_IMPL(psec2utils, pGpu, pKernelMIGGPUInstance)

void sec2utilsDestruct_IMPL(struct Sec2Utils *psec2utils);
#define __nvoc_sec2utilsDestruct(psec2utils) sec2utilsDestruct_IMPL(psec2utils)

NV_STATUS sec2utilsMemset_IMPL(struct Sec2Utils *psec2utils, SEC2UTILS_MEMSET_PARAMS *pParams);
#ifdef __nvoc_sec2_utils_h_disabled
static inline NV_STATUS sec2utilsMemset(struct Sec2Utils *psec2utils, SEC2UTILS_MEMSET_PARAMS *pParams) {
    NV_ASSERT_FAILED_PRECOMP("Sec2Utils was disabled!");
    return NV_ERR_NOT_SUPPORTED;
}
#else // __nvoc_sec2_utils_h_disabled
#define sec2utilsMemset(psec2utils, pParams) sec2utilsMemset_IMPL(psec2utils, pParams)
#endif // __nvoc_sec2_utils_h_disabled

NvU64 sec2utilsUpdateProgress_IMPL(struct Sec2Utils *psec2utils);
#ifdef __nvoc_sec2_utils_h_disabled
static inline NvU64 sec2utilsUpdateProgress(struct Sec2Utils *psec2utils) {
    NV_ASSERT_FAILED_PRECOMP("Sec2Utils was disabled!");
    return 0;
}
#else // __nvoc_sec2_utils_h_disabled
#define sec2utilsUpdateProgress(psec2utils) sec2utilsUpdateProgress_IMPL(psec2utils)
#endif // __nvoc_sec2_utils_h_disabled

void sec2utilsServiceInterrupts_IMPL(struct Sec2Utils *psec2utils);
#ifdef __nvoc_sec2_utils_h_disabled
static inline void sec2utilsServiceInterrupts(struct Sec2Utils *psec2utils) {
    NV_ASSERT_FAILED_PRECOMP("Sec2Utils was disabled!");
}
#else // __nvoc_sec2_utils_h_disabled
#define sec2utilsServiceInterrupts(psec2utils) sec2utilsServiceInterrupts_IMPL(psec2utils)
#endif // __nvoc_sec2_utils_h_disabled


// Wrapper macros for halified functions

// Dispatch functions
// Virtual method declarations and/or inline definitions
// Exported method declarations and/or inline definitions
// HAL method declarations without bodies
// Inline HAL method definitions
// Static dispatch method declarations
// Static inline method definitions
#undef PRIVATE_FIELD


#endif // SEC2_UTILS_H

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _G_SEC2_UTILS_NVOC_H_
