|
| 1 | +--- |
| 2 | +title: VGPU type identifiers |
| 3 | +layout: default |
| 4 | +design_doc: true |
| 5 | +revision: 1 |
| 6 | +status: proposed |
| 7 | +design_review: 156 |
| 8 | +revision_history: |
| 9 | +- revision_number: 1 |
| 10 | + description: Initial version |
| 11 | +--- |
| 12 | + |
| 13 | +Introduction |
| 14 | +------------ |
| 15 | + |
| 16 | +When xapi starts, it may create a number of VGPU_type objects. These act as |
| 17 | +VGPU presets, and exactly which VGPU_type objects are created depends on the |
| 18 | +installed hardware and in certain cases the presence of certain files in dom0. |
| 19 | + |
| 20 | +When deciding which VGPU_type objects need to be created, xapi needs to |
| 21 | +determine whether a suitable VGPU_type object already exists, as there should |
| 22 | +never be duplicates. At the moment the combination of vendor name and model name |
| 23 | +is used as a primary key, but this is not ideal as these values are subject to |
| 24 | +change. We therefore need a way of creating a primary key to uniquely identify |
| 25 | +VGPU_type objects. |
| 26 | + |
| 27 | +Identifier |
| 28 | +---------- |
| 29 | + |
| 30 | +We will add a new read-only field to the database: |
| 31 | + |
| 32 | +- `VGPU_type.identifier (string)` |
| 33 | + |
| 34 | +This field will contain a string representation of the parameters required to |
| 35 | +uniquely identify a VGPU_type. The parameters required can be summed up with the |
| 36 | +following OCaml type: |
| 37 | + |
| 38 | +``` |
| 39 | +type nvidia_id = { |
| 40 | + pdev_id : int; |
| 41 | + psubdev_id : int option; |
| 42 | + vdev_id : int; |
| 43 | + vsubdev_id : int; |
| 44 | +} |
| 45 | +
|
| 46 | +type gvt_g_id = { |
| 47 | + pdev_id : int; |
| 48 | + low_gm_sz : int64; |
| 49 | + high_gm_sz : int64; |
| 50 | + fence_sz : int64; |
| 51 | + monitor_config_file : string option; |
| 52 | +} |
| 53 | +
|
| 54 | +type t = |
| 55 | + | Passthrough |
| 56 | + | Nvidia of nvidia_id |
| 57 | + | GVT_g of gvt_g_id |
| 58 | +``` |
| 59 | + |
| 60 | +When converting this type to a string, the string will always be prefixed with |
| 61 | +`0001:` enabling future versioning of the serialisation format. |
| 62 | + |
| 63 | +For passthrough, the string will simply be: |
| 64 | + |
| 65 | +`0001:passthrough` |
| 66 | + |
| 67 | +For NVIDIA, the string will be `nvidia` followed by the four device IDs |
| 68 | +serialised as four-digit hex values, separated by commas. If `psubdev_id` is |
| 69 | +`None`, the empty string will be used e.g. |
| 70 | + |
| 71 | +``` |
| 72 | +Nvidia { |
| 73 | + pdev_id = 0x11bf; |
| 74 | + psubdev_id = None; |
| 75 | + vdev_id = 0x11b0; |
| 76 | + vsubdev_id = 0x109d; |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +would map to |
| 81 | + |
| 82 | +`0001:nvidia,11bf,,11b0,109d` |
| 83 | + |
| 84 | +For GVT-g, the string will be `gvt-g` followed by the physical device ID encoded |
| 85 | +as four-digit hex, followed by `low_gm_sz`, `high_gm_sz` and `fence_sz` encoded |
| 86 | +as hex, followed by `monitor_config_file` (or the empty string if it is `None`) |
| 87 | +e.g. |
| 88 | + |
| 89 | +``` |
| 90 | +GVT_g { |
| 91 | + pdev_id = 0x162a; |
| 92 | + low_gm_sz = 128L; |
| 93 | + high_gm_sz = 384L; |
| 94 | + fence_sz = 4L; |
| 95 | + monitor_config_file = None; |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +would map to |
| 100 | + |
| 101 | +`0001:gvt-g,162a,80,180,4,,` |
| 102 | + |
| 103 | +Having this string in the database will allow us to do a simple lookup to test |
| 104 | +whether a certain VGPU_type already exists. Although it is not currently |
| 105 | +required, this string can also be converted back to the type from which it was |
| 106 | +generated. |
| 107 | + |
| 108 | +When deciding whether to create VGPU_type objects, xapi will generate the |
| 109 | +identifier string and use it to look for existing VGPU_type objects in the |
| 110 | +database. If none are found, xapi will look for existing VGPU_type objects with |
| 111 | +the tuple of model name and vendor name. If still none are found, xapi will |
| 112 | +create a new VGPU_type object. |
0 commit comments