CUcontext current_ctx;
CUcontext input_ctx;
- if (dev == NULL)
- return -ENODEV;
+ if (dev == NULL) {
+ rte_errno = ENODEV;
+ return -rte_errno;
+ }
/* Child initialization time probably called by rte_gpu_add_child() */
if (dev->mpshared->info.parent != RTE_GPU_ID_NONE &&
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxGetCurrent failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Set child ctx as current ctx */
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent input failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/*
(uint32_t)affinityPrm.param.smCount.val;
ret = rte_gpu_info_get(dev->mpshared->info.parent, &parent_info);
- if (ret)
- return -ENODEV;
+ if (ret) {
+ rte_errno = ENODEV;
+ return -rte_errno;
+ }
dev->mpshared->info.total_memory = parent_info.total_memory;
/*
RTE_CACHE_LINE_SIZE);
if (dev->mpshared->dev_private == NULL) {
rte_cuda_log(ERR, "Failed to allocate memory for GPU process private");
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
private = (struct cuda_info *)dev->mpshared->dev_private;
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxGetDevice failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
res = pfn_cuDeviceGetName(private->gpu_name,
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceGetName failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Restore original ctx as current ctx */
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
}
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxGetCurrent failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Set child ctx as current ctx */
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent input failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Get next memory list item */
mem_alloc_list_tail = mem_list_add_item();
- if (mem_alloc_list_tail == NULL)
- return -ENOMEM;
+ if (mem_alloc_list_tail == NULL) {
+ rte_errno = EPERM;
+ return -rte_errno;
+ }
/* Allocate memory */
mem_alloc_list_tail->size = size;
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* GPUDirect RDMA attribute required */
rte_cuda_log(ERR, "Could not set SYNC MEMOP attribute for "
"GPU memory at %"PRIu32", err %d",
(uint32_t)mem_alloc_list_tail->ptr_d, res);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
mem_alloc_list_tail->pkey = get_hash_from_ptr((void *)mem_alloc_list_tail->ptr_d);
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
*ptr = (void *)mem_alloc_list_tail->ptr_d;
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxGetCurrent failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Set child ctx as current ctx */
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent input failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Get next memory list item */
mem_alloc_list_tail = mem_list_add_item();
- if (mem_alloc_list_tail == NULL)
- return -ENOMEM;
+ if (mem_alloc_list_tail == NULL) {
+ rte_errno = EPERM;
+ return -rte_errno;
+ }
/* Allocate memory */
mem_alloc_list_tail->size = size;
err_string,
mem_alloc_list_tail->ptr_h,
mem_alloc_list_tail->size);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
res = pfn_cuDeviceGetAttribute(&(use_ptr_h),
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceGetAttribute failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
if (use_ptr_h == 0) {
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuMemHostGetDevicePointer failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
if ((uintptr_t)mem_alloc_list_tail->ptr_d !=
(uintptr_t)mem_alloc_list_tail->ptr_h) {
rte_cuda_log(ERR, "Host input pointer is different wrt GPU registered pointer");
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
} else {
mem_alloc_list_tail->ptr_d = (CUdeviceptr)mem_alloc_list_tail->ptr_h;
if (res != 0) {
rte_cuda_log(ERR, "Could not set SYNC MEMOP attribute for GPU memory at %"PRIu32
", err %d", (uint32_t)mem_alloc_list_tail->ptr_d, res);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
mem_alloc_list_tail->pkey = get_hash_from_ptr((void *)mem_alloc_list_tail->ptr_h);
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
return 0;
mem_item = mem_list_find_item(hk);
if (mem_item == NULL) {
rte_cuda_log(ERR, "Memory address 0x%p not found in driver memory", ptr);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
if (mem_item->mtype == GPU_MEM) {
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuMemFree current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
return mem_list_del_item(hk);
mem_item = mem_list_find_item(hk);
if (mem_item == NULL) {
rte_cuda_log(ERR, "Memory address 0x%p not found in driver memory", ptr);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
if (mem_item->mtype == CPU_REGISTERED) {
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuMemHostUnregister current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
return mem_list_del_item(hk);
rte_cuda_log(ERR, "Memory type %d not supported", mem_item->mtype);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
static int
CUcontext input_ctx;
struct cuda_info *private;
- if (dev == NULL)
- return -ENODEV;
+ if (dev == NULL) {
+ rte_errno = ENODEV;
+ return -rte_errno;
+ }
private = (struct cuda_info *)dev->mpshared->dev_private;
*/
rte_cuda_log(WARNING, "Can't flush GDR writes with cuFlushGPUDirectRDMAWrites CUDA function."
"Application needs to use alternative methods.");
- return -ENOTSUP;
+
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
/* Store current ctx */
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxGetCurrent failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Set child ctx as current ctx */
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent input failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
res = pfn_cuFlushGPUDirectRDMAWrites(CU_FLUSH_GPU_DIRECT_RDMA_WRITES_TARGET_CURRENT_CTX,
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuFlushGPUDirectRDMAWrites current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/* Restore original ctx as current ctx */
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuCtxSetCurrent current failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
return 0;
if (pci_dev == NULL) {
rte_cuda_log(ERR, "NULL PCI device");
- return -EINVAL;
+ rte_errno = ENODEV;
+ return -rte_errno;
}
rte_pci_device_name(&pci_dev->addr, dev_name, sizeof(dev_name));
/* Allocate memory to be used privately by drivers */
dev = rte_gpu_allocate(pci_dev->device.name);
- if (dev == NULL)
- return -ENODEV;
+ if (dev == NULL) {
+ rte_errno = ENODEV;
+ return -rte_errno;
+ }
/* Initialize values only for the first CUDA driver call */
if (dev->mpshared->info.dev_id == 0) {
/* Load libcuda.so library */
if (cuda_loader()) {
rte_cuda_log(ERR, "CUDA Driver library not found");
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
/* Load initial CUDA functions */
if (cuda_sym_func_loader()) {
rte_cuda_log(ERR, "CUDA functions not found in library");
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
/*
res = sym_cuDriverGetVersion(&cuda_driver_version);
if (res != 0) {
rte_cuda_log(ERR, "cuDriverGetVersion failed with %d", res);
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
if (cuda_driver_version < CUDA_DRIVER_MIN_VERSION) {
"Minimum requirement is %d",
cuda_driver_version,
CUDA_DRIVER_MIN_VERSION);
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
if (cuda_pfn_func_loader()) {
rte_cuda_log(ERR, "CUDA PFN functions not found in library");
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
}
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceGetByPCIBusId name %s failed with %d: %s",
dev->device->name, res, err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
res = pfn_cuDevicePrimaryCtxRetain(&pctx, cu_dev_id);
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDevicePrimaryCtxRetain name %s failed with %d: %s",
dev->device->name, res, err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
res = pfn_cuCtxGetApiVersion(pctx, &cuda_api_version);
if (res != 0) {
rte_cuda_log(ERR, "cuCtxGetApiVersion failed with %d", res);
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
if (cuda_api_version < CUDA_API_MIN_VERSION) {
rte_cuda_log(ERR, "CUDA API version found is %d Minimum requirement is %d",
cuda_api_version, CUDA_API_MIN_VERSION);
- return -ENOTSUP;
+ rte_errno = ENOTSUP;
+ return -rte_errno;
}
dev->mpshared->info.context = (uint64_t)pctx;
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceGetAttribute failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
dev->mpshared->info.processor_count = (uint32_t)processor_count;
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceTotalMem failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
/*
RTE_CACHE_LINE_SIZE);
if (dev->mpshared->dev_private == NULL) {
rte_cuda_log(ERR, "Failed to allocate memory for GPU process private");
- return -ENOMEM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
private = (struct cuda_info *)dev->mpshared->dev_private;
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceGetName failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
res = pfn_cuDeviceGetAttribute(&(private->gdr_supported),
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceGetAttribute failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
if (private->gdr_supported == 0)
rte_cuda_log(ERR,
"cuDeviceGetAttribute failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
if (private->gdr_write_ordering == CU_GPU_DIRECT_RDMA_WRITES_ORDERING_NONE) {
pfn_cuGetErrorString(res, &(err_string));
rte_cuda_log(ERR, "cuDeviceGetAttribute failed with %s",
err_string);
- return -EPERM;
+ rte_errno = EPERM;
+ return -rte_errno;
}
if (private->gdr_flush_type != CU_FLUSH_GPU_DIRECT_RDMA_WRITES_OPTION_HOST)
int ret;
uint8_t gpu_id;
- if (pci_dev == NULL)
- return -EINVAL;
+ if (pci_dev == NULL) {
+ rte_errno = ENODEV;
+ return -rte_errno;
+ }
dev = rte_gpu_get_by_name(pci_dev->device.name);
if (dev == NULL) {
rte_cuda_log(ERR, "Couldn't find HW dev \"%s\" to uninitialise it",
pci_dev->device.name);
- return -ENODEV;
+ rte_errno = ENODEV;
+ return -rte_errno;
}
gpu_id = dev->mpshared->info.dev_id;