1 # SPDX-FileCopyrightText: 2021 Intel Corporation.
3 # SPDX-License-Identifier: Apache-2.0
6 # check if the selected driver module is available on host
7 - name: Check that selected driver module is available
8 # if modinfo fails, lookup loaded modules as modinfo might return error
9 # for igb_uio and potentially other modules not included with the kernel
10 shell: "modinfo {{ vf_driver.value }} || grep {{ vf_driver.value }} /proc/modules || grep {{ vf_driver.value }} /lib/modules/$(uname -r)/modules.builtin"
11 register: shell_result
15 with_dict: "{{ item.sriov_vfs | default({}) | combine({'default': item.default_vf_driver}) }}"
19 - name: pre-create empty dict for VFs
23 - name: populate VFs dict with values
25 vfs_acc: "{{ vfs_acc | combine({idx : item.default_vf_driver}) }}"
26 loop: "{{ range(item.sriov_numvfs | default(0) | int) | list }}"
31 - name: update VFs dict with default drivers
33 vfs_acc: "{{ vfs_acc | combine({vf.key | regex_replace('.*_(\\d*)', '\\1') | int : vf.value}) }}"
34 loop: "{{ item.sriov_vfs | default({}) | dict2items | sort(attribute='key') }}"
38 when: ansible_loop.index < (item.sriov_numvfs | default(0) | int )
40 # get a list of VFs PCI addresses and save the configuration
41 - name: attach VFs driver
43 - name: fetch VFs pci addresses for a PF
44 shell: "for vf in /sys/class/net/{{ item.name }}/device/virtfn*;do basename $(readlink -f $vf);done | sort"
50 - name: save VF driver binding
52 path: "{{ sriov_config_path }}/bmra_interfaces"
53 line: "{{ this_item[0] }} {{ this_item[1].value }}"
54 regexp: "^{{ this_item[0] }}"
59 loop: "{{ vf_pciids.stdout_lines | zip(vfs_acc | dict2items) | list }}"
63 - vf_pciids.stderr|length == 0
64 - vf_pciids.stdout_lines|length > 0
65 when: shell_result.results | sum(attribute='rc') == 0