/* * Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2020. All rights reserved. * Description: This file contains api definition for Device Management. * Author: Hisilicon * Create: 2019-11-28 */ #ifndef MPI_NPU_DRVMM_H #define MPI_NPU_DRVMM_H #include "td_type.h" #include "npu_common_ext.h" struct DMA_ADDR { td_void *src; td_void *dst; td_u32 len; td_u8 flag; td_u32 fixed_size; td_void *priv; }; struct DMA_ARG { td_u32 devid; td_u32 offset; }; #define DV_MEM_SVM 0x0001 #define DV_MEM_SVM_HOST 0x0002 #define DV_MEM_SVM_DEVICE 0x0004 #define DV_MEM_LOCK_HOST 0x0008 #define DV_MEM_LOCK_DEV 0x0010 #define DV_MEM_LOCK_DEV_DVPP 0x0020 #define DV_MEM_RESV 8 struct DVattribute { /* *< DV_MEM_SVM_DEVICE : svm memory & mapped device */ /* *< DV_MEM_SVM_HOST : svm memory & mapped host */ /* *< DV_MEM_SVM : svm memory & no mapped */ /* *< DV_MEM_LOCK_HOST : host mapped memory & lock host */ /* *< DV_MEM_LOCK_DEV : dev mapped memory & lock dev */ /* *< DV_MEM_LOCK_DEV_DVPP : dev_dvpp mapped memory & lock dev */ unsigned int mem_type; unsigned int resv1; unsigned int resv2; unsigned int dev_id; unsigned int page_size; unsigned int resv[DV_MEM_RESV]; }; #define COMPUTE_GROUP_INFO_RES_NUM 8 struct capability_group_info { unsigned int group_id; unsigned int state; // 0: not create, 1: created unsigned int extend_attribute; // 0: default group attribute unsigned int aicore_number; // 0~9 unsigned int aivector_number; // 0~7 unsigned int sdma_number; // 0~15 unsigned int aicpu_number; // 0~15 unsigned int active_sq_number; unsigned int res[COMPUTE_GROUP_INFO_RES_NUM]; }; struct MemInfo { unsigned long normal_total; unsigned long normal_free; unsigned long huge_total; unsigned long huge_free; }; drvError_t drvMemSmmuQuery(td_u32 device, td_u32 *SSID); drvError_t drvMemAddressTranslate(td_u64 vptr, td_u64 *pptr); drvError_t drvMemsetD8(td_u64 dst, size_t destMax, td_u8 value, size_t size); drvError_t halMemGetInfo(td_u32 device, int type, struct MemInfo *info); drvError_t halMemCtl(int type, void *param_value, size_t param_value_size, void *out_value, size_t *out_size_ret); drvError_t drvMemcpy(td_u64 dst, td_u64 destMax, td_u64 src, td_u64 size); drvError_t halMemAlloc(td_void **pp, td_u64 size, td_u64 flag); drvError_t halMemFree(td_void *pp); /* This function is used to judge if program is loaded into L2buf. We do not need this function */ drvError_t drvLoadProgram(td_u32 deviceId, td_void *program, td_u32 offset, size_t ByteCount, td_void **vPtr); /* offline need not to support this interface */ drvError_t drvMemConvertAddr(td_u64 pSrc, td_u64 pDst, td_u32 len, td_u32 *out_len, struct DMA_ARG *dma); /* offline need not to support this interface */ drvError_t drvMemDestroyAddr(struct DMA_ARG dma); /* offline need not to support this interface */ drvError_t drvMemPrefetchToDevice(td_u64 devPtr, size_t len, td_u32 device); /* offline need not to support this interface */ drvError_t drvMemGetAttribute(td_u64 vptr, struct DVattribute *addtr); /* offline need not to support this interface */ drvError_t halShmemCreateHandle(td_u64 vptr, td_u64 byteCount, td_char *name, td_u32 len); /* offline need not to support this interface */ drvError_t halShmemOpenHandle(const char *name, td_u64 *vptr); /* offline need not to support this interface */ drvError_t halShmemCloseHandle(td_u64 vptr); /* offline need not to support this interface */ drvError_t halShmemDestroyHandle(const td_char *name); /* offline need not to support this interface */ drvError_t halShmemSetPidHandle(const char *name, int pid[], int num); /* offline need not to support this interface */ drvError_t drvMemIonFlushCache(td_u64 addr, size_t ByteCount); /* offline need not to support this interface */ drvError_t drvMemDeviceOpen(unsigned int devid, int devfd); /* offline need not to support this interface */ drvError_t drvMemDeviceClose(unsigned int devid); /* We not use L2 buffer */ drvError_t drvMemAllocL2buffAddr(td_u32 device, td_void **l2buff, td_u64 *pte); /* We not use L2 buffer */ drvError_t drvMemReleaseL2buffAddr(td_u32 device, td_void *l2buff); drvError_t drvMemcpyDtoH(td_u64 dst, size_t dst_max, td_u64 src, size_t byte_count); drvError_t halGetCapabilityGroupInfo(int deviceId, int ownerId, int groupId, struct capability_group_info *groupInfo, int groupCount); #endif