summaryrefslogtreecommitdiffstats
path: root/sw_config/bmra/patched_vfio.yml
blob: c0a6e25fd49e205bbeaaa4964c43e09c7e0bcad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##
##   Copyright (c) 2020 Intel Corporation.
##
##   Licensed under the Apache License, Version 2.0 (the "License");
##   you may not use this file except in compliance with the License.
##   You may obtain a copy of the License at
##
##       http://www.apache.org/licenses/LICENSE-2.0
##
##   Unless required by applicable law or agreed to in writing, software
##   distributed under the License is distributed on an "AS IS" BASIS,
##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##   See the License for the specific language governing permissions and
##   limitations under the License.
##
---
# check if the selected driver module is available on host
- name: Check that selected driver module is available
  # if modinfo fails, lookup loaded modules as modinfo might return error
  # for igb_uio and potentially other modules not included with the kernel
  shell: "modinfo {{ vf_driver }} || grep {{ vf_driver }} /proc/modules || grep {{ vf_driver }} /lib/modules/$(uname -r)/modules.builtin"
  register: shell_result
  ignore_errors: yes
  failed_when: no
  changed_when: no

# get a list of VFs PCI addresses and save the configuration
- name: attach VFs driver
  block:
    - name: fetch VFs pci addresses for a PF
      shell: "for vf in /sys/class/net/{{ pfname }}/device/virtfn*;do basename $(readlink -f $vf);done"
      register: vf_pciids
      args:
        executable: /bin/bash
      changed_when: false

    - name: save VF driver binding
      lineinfile:
        path: "{{ sriov_config_path }}/bmra_interfaces"
        line: "{{ this_item }} {{ vf_driver }}"
        regexp: "^{{ this_item }}"
        create: yes
        owner: root
        group: root
        mode: '0600'
      loop: "{{ vf_pciids.stdout_lines }}"
      loop_control:
        loop_var: this_item
      when:
        - vf_pciids.stderr|length == 0
        - vf_pciids.stdout_lines|length > 0
  when: shell_result.rc == 0