config_tools: Update GPU passthrough support

1. Remove gvt_args field.
2. Add passthrough GPU devices support.
3. Add sriov device support.

Tracked-On: #6290
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
Weiyi Feng
2021-11-02 15:11:52 +08:00
committed by wenlingz
parent f65a87585b
commit 20f1dfd9c3
9 changed files with 143 additions and 62 deletions

View File

@@ -200,18 +200,23 @@ def media_pt(user_vm_type, sel, vmid, config):
audio_pt(user_vm_type, sel, vmid, config)
def gen_pt(names, dm, sel, vmid, config):
def gen_pt(names, dm, sriov, sel, vmid, config):
pt_none = True
cap_pt = launch_cfg_lib.get_pt_dev()
user_vm_type = names['user_vm_types'][vmid]
print("modprobe pci_stub", file=config)
# pass thru GPU
if dm['gvt_args'][vmid] == "gvtd":
# SRIOV passthru
if sriov['gpu'][vmid]:
print('echo ${passthru_vpid["gpu"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind', file=config)
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
if sriov['network'][vmid]:
print('echo ${passthru_vpid["network"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
print('echo ${passthru_bdf["network"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind',
file=config)
print('echo ${passthru_bdf["network"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
for pt_dev in cap_pt:
if sel.bdf[pt_dev][vmid]:
@@ -227,7 +232,7 @@ def gen_pt(names, dm, sel, vmid, config):
media_pt(user_vm_type, sel, vmid, config)
def gen_pt_head(names, dm, sel, vmid, config):
def gen_pt_head(names, dm, sriov, sel, vmid, config):
cap_pt = launch_cfg_lib.get_pt_dev()
user_vm_type = names['user_vm_types'][vmid]
@@ -242,9 +247,13 @@ def gen_pt_head(names, dm, sel, vmid, config):
if not sel.vpid[pt_dev] or not sel.vpid[pt_dev][vmid]:
continue
print('["{}"]="{}"'.format(pt_dev, sel.vpid[pt_dev][vmid]), file=config)
if dm['gvt_args'][vmid] == "gvtd":
gpu_vpid = launch_cfg_lib.get_gpu_vpid()
print('["gpu"]="{}"'.format(gpu_vpid), file=config)
# SRIOV passthru
if sriov['gpu'][vmid]:
print('["gpu"]="{}"'.format(launch_cfg_lib.get_gpu_vpid()), file=config)
if sriov['network'][vmid]:
print('["network"]="{}"'.format(launch_cfg_lib.get_vpid_by_bdf(sriov['network'][vmid])), file=config)
print(')', file=config)
print("passthru_bdf=(", file=config)
@@ -252,9 +261,10 @@ def gen_pt_head(names, dm, sel, vmid, config):
if not sel.bdf[pt_dev] or not sel.bdf[pt_dev][vmid]:
continue
print('["{}"]="0000:{}"'.format(pt_dev, sel.bdf[pt_dev][vmid]), file=config)
if dm['gvt_args'][vmid] == "gvtd":
gpu_bdf = launch_cfg_lib.get_gpu_bdf()
print('["gpu"]="0000:{}"'.format(gpu_bdf), file=config)
if sriov['gpu'][vmid]:
print('["gpu"]="0000:{}"'.format(sriov['gpu'][vmid]), file=config)
if sriov['network'][vmid]:
print('["network"]="0000:{}"'.format(sriov['network'][vmid]), file=config)
print(')', file=config)
print("", file=config)