Fix a set of issues with K8s deployment
[kuberef.git] / sw_config / bmra / dpdk_patch.yml
1 ##
2 ##   Copyright (c) 2020 Intel Corporation.
3 ##
4 ##   Licensed under the Apache License, Version 2.0 (the "License");
5 ##   you may not use this file except in compliance with the License.
6 ##   You may obtain a copy of the License at
7 ##
8 ##       http://www.apache.org/licenses/LICENSE-2.0
9 ##
10 ##   Unless required by applicable law or agreed to in writing, software
11 ##   distributed under the License is distributed on an "AS IS" BASIS,
12 ##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ##   See the License for the specific language governing permissions and
14 ##   limitations under the License.
15 ##
16 ---
17 - name: install dependencies
18   include_role:
19     name: install_dependencies
20
21 - name: download DPDK
22   unarchive:
23     src: "{{ dpdk_url }}"
24     dest: "/usr/src"
25     remote_src: yes
26     list_files: yes
27     mode: 0755
28   register: dpdk_download
29
30 - name: set local dpdk directory path
31   set_fact:
32     dpdk_dir: "{{ dpdk_download.dest  }}/{{ dpdk_download.files[0] }}"
33
34 - name: run make config
35   make:
36     chdir: "{{ dpdk_dir }}"
37     target: config
38     params:
39       T: "{{ dpdk_target }}"
40
41 - name: update ansible_kernel fact
42   setup:
43     filter: 'ansible_kernel'
44
45 - name: patch DPDK (kni)
46   lineinfile:
47     path: "{{ dpdk_dir }}/kernel/linux/kni/kni_net.c"
48     regexp: '^\s*kni_net_tx_timeout'
49     line: 'kni_net_tx_timeout(struct net_device *dev, unsigned int txqueue)'
50   when:
51     - ansible_distribution == "CentOS"
52     - ansible_distribution_major_version == '8'
53     - ansible_kernel is version('4.18.0-240','>=')
54
55 - name: enable virtio-user support
56   lineinfile:
57     path: "{{ dpdk_dir }}/build/.config"
58     regexp: '^CONFIG_RTE_VIRTIO_USER'
59     line: 'CONFIG_RTE_VIRTIO_USER=y'
60     mode: 0600
61
62 - name: enable PCAP PMD support
63   lineinfile:
64     path: "{{ dpdk_dir }}/build/.config"
65     regexp: '^CONFIG_RTE_LIBRTE_PMD_PCAP'
66     line: 'CONFIG_RTE_LIBRTE_PMD_PCAP=y'
67     mode: 0600
68
69 - name: build DPDK
70   make:
71     target: install
72     chdir: "{{ dpdk_dir }}"
73     params:
74       T: "{{ dpdk_target }}"
75       DESTDIR: install
76       prefix: "/usr"
77
78 - name: find dpdk tools
79   find:
80     path: "{{ dpdk_dir }}"
81     patterns: "dpdk-devbind.py"
82     recurse: yes
83   register: dpdk_tools_dir
84
85 - name: set path to dpdk usertools directory
86   set_fact:
87     dpdk_tools: "{{ dpdk_tools_dir.files[0].path }}"
88
89 - name: load userspace modules
90   modprobe:
91     name: "{{ item }}"
92     state: present
93   with_items:
94     - vfio-pci
95     - uio
96
97 - name: install dpdk-devbind.py in /usr/local/bin
98   copy:
99     remote_src: yes
100     src: "{{ dpdk_tools }}"
101     dest: "/usr/local/bin/dpdk-devbind.py"
102     mode: 0700
103     owner: root
104     group: root
105   become: yes
106
107 - name: load intel module
108   command: "insmod {{ dpdk_dir }}/{{ dpdk_target }}/kmod/igb_uio.ko"
109   register: result
110   failed_when: "'No such file or directory' in result.stderr"
111   changed_when: "'already bound' not in result.stderr"