Skip to content

Commit

Permalink
Add systemd for binding dpdk port after reboot
Browse files Browse the repository at this point in the history
- Add dpdkbind.service for systemd
- Update kernel module from uio to igb_uio
cc linkernetworks/vortex#212
  • Loading branch information
sufuf3 committed Aug 6, 2018
1 parent 9f64815 commit ecc430c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 7 deletions.
2 changes: 1 addition & 1 deletion inventory/group_vars/network-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ ovs_tar_path: /tmp/openvswitch-2.9.2.tar.gz
ovs_folder_name: openvswitch-2.9.2

### Kernel module ###
kernel_module: uio
kernel_module: igb_uio
2 changes: 1 addition & 1 deletion network-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- hosts: network-setup
become: yes
roles:
- { role: network-setup/dpdk, when: kernel_module == 'uio' or ovs_type == 'dpdk', tags: dpdk }
- { role: network-setup/dpdk, when: kernel_module == 'igb_uio' or ovs_type == 'dpdk', tags: dpdk }
- { role: network-setup/ovs, when: ovs_type == 'ovs', tags: ovs }
- { role: network-setup/dpdk-ovs, when: ovs_type == 'dpdk', tags: dpdk-ovs }
- { role: network-setup/setup-dpdk-ovs, when: ovs_type == 'dpdk', tags: dpdk-ovs }
Expand Down
4 changes: 2 additions & 2 deletions roles/network-setup/dpdk/tasks/bind-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

# Bind port
- name: Bind port
shell: cd ~/ && {{ DPDK_DIR }}/usertools/dpdk-devbind.py --bind=igb_uio {{ item.name }}
shell: cd ~/ && {{ DPDK_DIR }}/usertools/dpdk-devbind.py --bind={{ kernel_module }} {{ item.name }}
ignore_errors: True
with_items:
- "{{ dpdk_ifaces }}"
when: ovs_type == 'dpdk'
when: ovs_type == 'dpdk' and kernel_module == 'igb_uio'

# Check port
- name: Check port
Expand Down
26 changes: 26 additions & 0 deletions roles/network-setup/dpdk/tasks/dpdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,29 @@
command: sed -i 's/CONFIG_RTE_BUILD_SHARED_LIB=n/CONFIG_RTE_BUILD_SHARED_LIB=y/g' {{ DPDK_DIR }}/config/common_base
when: ovs_type == 'dpdk'

# NIC setup will binding dpdk port after reboot
- name: Copy dpdkbind.service file
template:
src: dpdkbind.service.j2
dest: "/etc/systemd/system/dpdkbind.service"
owner: root
group: root
mode: 0755
when: ovs_type == 'dpdk'

- name: Copy dpdkbind file
template:
src: dpdkbind.j2
dest: "/etc/systemd/system/dpdkbind"
owner: root
group: root
mode: 0755
when: ovs_type == 'dpdk'

- name: Enable dpdkbind.service
command: "{{ item }}"
with_items:
- systemctl enable dpdkbind
- systemctl start dpdkbind
when: ovs_type == 'dpdk'

4 changes: 2 additions & 2 deletions roles/network-setup/dpdk/tasks/setting-kmod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- name: Insert igb_uio when kernal_module is UIO
command: insmod {{ DPDK_DIR }}/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
ignore_errors: True
when: kernel_module == 'uio' and ovs_type == 'dpdk'
when: kernel_module == 'igb_uio' and ovs_type == 'dpdk'

# Make uio and igb_uio installations persist across reboots
- name: Insert igb_uio when kernal_module is UIO
Expand All @@ -25,5 +25,5 @@
- depmod -a
- echo "uio" | sudo tee -a /etc/modules
- echo "igb_uio" | sudo tee -a /etc/modules
when: kernel_module == 'uio' and ovs_type == 'dpdk'
when: kernel_module == 'igb_uio' and ovs_type == 'dpdk'

4 changes: 4 additions & 0 deletions roles/network-setup/dpdk/templates/dpdkbind.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# eg, NET_IF_NAME=enp0s16,enp0s17
{% for item in dpdk_ifaces %}
NET_IF_NAME={{item.name}}
{%- endfor -%}
13 changes: 13 additions & 0 deletions roles/network-setup/dpdk/templates/dpdkbind.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Binding dpdk port after reboot
After=multi-user.target

[Install]
WantedBy=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=true
EnvironmentFile=-/etc/default/dpdkbind
ExecStart=/bin/bash -c 'echo "$NET_IF_NAME" | tr "," "\n" | awk \'{system("/sbin/ifconfig " $1 " down")}\''
ExecStart=/bin/bash -c 'echo "$NET_IF_NAME" | tr "," "\n" | awk \'{system("/usr/src/dpdk-stable-17.11.2/usertools/dpdk-devbind.py --bind={{ kernel_module }} " $1 )}\''
2 changes: 1 addition & 1 deletion roles/network-setup/reset/tasks/dpdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
- name: Remove IGB UIO module
shell: /sbin/rmmod igb_uio
ignore_errors: True
when: kernel_module == 'uio' and ovs_type == 'dpdk'
when: kernel_module == 'igb_uio' and ovs_type == 'dpdk'

# Unbind devices from VFIO driver
- name: Remove VFIO module
Expand Down

0 comments on commit ecc430c

Please sign in to comment.