| 1 |
#ifndef NV_DEVINFO_H |
| 2 |
#define NV_DEVINFO_H |
| 3 |
|
| 4 |
#include <stdbool.h> |
| 5 |
#include <string.h> |
| 6 |
|
| 7 |
#include "util/macros.h" |
| 8 |
|
| 9 |
#define NVIDIA_VENDOR_ID 0x10de |
| 10 |
|
| 11 |
enum ENUM_PACKED nv_device_type { |
| 12 |
NV_DEVICE_TYPE_IGP, |
| 13 |
NV_DEVICE_TYPE_DIS, |
| 14 |
NV_DEVICE_TYPE_SOC, |
| 15 |
}; |
| 16 |
|
| 17 |
/* Matches drm_nouveau_get_zcull_info */ |
| 18 |
struct nv_zcull_device_info { |
| 19 |
uint32_t width_align_pixels; |
| 20 |
uint32_t height_align_pixels; |
| 21 |
uint32_t pixel_squares_by_aliquots; |
| 22 |
uint32_t aliquot_total; |
| 23 |
uint32_t zcull_region_byte_multiplier; |
| 24 |
uint32_t zcull_region_header_size; |
| 25 |
uint32_t zcull_subregion_header_size; |
| 26 |
uint32_t subregion_count; |
| 27 |
uint32_t subregion_width_align_pixels; |
| 28 |
uint32_t subregion_height_align_pixels; |
| 29 |
|
| 30 |
uint32_t ctxsw_size; |
| 31 |
uint32_t ctxsw_align; |
| 32 |
}; |
| 33 |
|
| 34 |
struct nv_device_info { |
| 35 |
enum nv_device_type type; |
| 36 |
|
| 37 |
uint16_t device_id; |
| 38 |
uint16_t chipset; |
| 39 |
|
| 40 |
char device_name[64]; |
| 41 |
char chipset_name[16]; |
| 42 |
|
| 43 |
/* Populated if type != NV_DEVICE_TYPE_SOC */ |
| 44 |
struct { |
| 45 |
uint16_t domain; |
| 46 |
uint8_t bus; |
| 47 |
uint8_t dev; |
| 48 |
uint8_t func; |
| 49 |
uint8_t revision_id; |
| 50 |
} pci; |
| 51 |
|
| 52 |
uint8_t sm; /**< Shader model */ |
| 53 |
|
| 54 |
uint8_t gpc_count; |
| 55 |
uint16_t tpc_count; |
| 56 |
uint8_t mp_per_tpc; |
| 57 |
uint8_t max_warps_per_mp; |
| 58 |
|
| 59 |
bool has_transfer_queue; |
| 60 |
|
| 61 |
/** Non-coherent memory map atom size */ |
| 62 |
uint16_t nc_atom_size_B; |
| 63 |
|
| 64 |
uint16_t cls_copy; |
| 65 |
uint16_t cls_eng2d; |
| 66 |
uint16_t cls_eng3d; |
| 67 |
uint16_t cls_m2mf; |
| 68 |
uint16_t cls_compute; |
| 69 |
uint16_t cls_gpfifo; |
| 70 |
|
| 71 |
uint64_t vram_size_B; |
| 72 |
uint64_t bar_size_B; |
| 73 |
|
| 74 |
/* Max shared memory per workgroup */ |
| 75 |
uint16_t max_smem_per_wg_kB; |
| 76 |
|
| 77 |
/* Max shared memory configurations per MP. Those values matter for |
| 78 |
* occupancy calculations and describe legal shared memory splits we can |
| 79 |
* configure the hardware with. |
| 80 |
*/ |
| 81 |
uint16_t sm_smem_sizes_kB[10]; |
| 82 |
uint8_t sm_smem_size_count; |
| 83 |
|
| 84 |
struct nv_zcull_device_info zcull_info; |
| 85 |
bool has_zcull_info; |
| 86 |
}; |
| 87 |
|
| 88 |
static inline void |
| 89 |
nv_device_uuid(const struct nv_device_info *info, uint8_t *uuid, size_t len, bool vm_bind) |
| 90 |
{ |
| 91 |
uint16_t vendor_id = NVIDIA_VENDOR_ID; |
| 92 |
|
| 93 |
assert(len >= 16); |
| 94 |
|
| 95 |
memset(uuid, 0, len); |
| 96 |
memcpy(&uuid[0], &info->chipset, 2); |
| 97 |
memcpy(&uuid[2], &vendor_id, 2); |
| 98 |
memcpy(&uuid[4], &info->device_id, 2); |
| 99 |
|
| 100 |
if (info->type != NV_DEVICE_TYPE_SOC) { |
| 101 |
memcpy(&uuid[6], &info->pci.domain, 2); |
| 102 |
uuid[8] = info->pci.bus; |
| 103 |
uuid[9] = info->pci.dev; |
| 104 |
uuid[10] = info->pci.func; |
| 105 |
} |
| 106 |
uuid[11] = vm_bind; |
| 107 |
} |
| 108 |
|
| 109 |
#endif /* NV_DEVINFO_H */ |