Add VLAN support to DPDK on VF

- functions updated to support vlan
- config creation for vlan interface added
- PciPassthroughFilter returned to scheduler config

Change-Id: Ied756fc800b02a8caebebc75416e06f7907d9d2b
Signed-off-by: Illia Polliul <ipolliul@mirantis.com>
This commit is contained in:
Illia Polliul 2016-09-17 22:29:40 +03:00 committed by Oleksandr Martsyniuk
parent 55c5aa783a
commit 09dd47ccdb
6 changed files with 69 additions and 21 deletions

View File

@ -25,11 +25,14 @@ module Puppet::Parser::Functions
sriov_hash = function_get_sriov_devices([])
network_scheme = function_hiera_hash(['network_scheme', {}])
list = function_get_nic_passthrough_whitelist(['sriov'])
list = []
if function_get_nic_passthrough_whitelist(['sriov'])
list += function_get_nic_passthrough_whitelist(['sriov'])
end
if dpdk_on_vf
hiera_data_key = "priv_int_vfn_wl"
priv_int = args[2]
priv_int = args[2].sub(/\..*/, '')
dpdk_vf_number = args[3]
if (File.exists?("/sys/class/net/#{priv_int}"))
vfn = Dir.glob "/sys/class/net/#{priv_int}/device/virtfn*"

View File

@ -38,7 +38,7 @@ module Puppet::Parser::Functions
if dpdk_on_vf
hiera_data_key = "priv_int_sriov_data"
private_interface = args[1]
private_interface = args[1].sub(/\..*/, '')
private_interface_path = "/sys/class/net/" + private_interface
if (File.exists?(private_interface_path + "/device/sriov_totalvfs"))
sriov_hash[private_interface] = Hash.new

View File

@ -20,7 +20,7 @@ module Puppet::Parser::Functions
EOS
) do |args|
dev_name = args[0]
dev_name = args[0].sub(/\..*/, '')
vf_number = args[1]
vf_sys = "/sys/class/net/#{dev_name}/device/virtfn#{vf_number}"
vf_data = Hash.new

View File

@ -38,25 +38,16 @@ class contrail::compute::network {
# Configure persistent network device for DPDK VF
if $contrail::compute_dpdk_on_vf {
$vlan_tag = regsubst($::contrail::phys_dev, '^.+\.' , '')
$vf_data = get_vf_data($contrail::phys_dev, $contrail::dpdk_vf_number)
$dpdk_dev_name = "dpdk-vf${contrail::dpdk_vf_number}"
$dpdk_vf_origin_name = $vf_data['vf_dev_name']
$dpdk_dev_pci = $vf_data['vf_pci_addr']
$dpdk_dev_mac = $vf_data['vf_mac_addr']
$raw_phys_dev = regsubst($::contrail::phys_dev, '\..*' , '')
exec { 'rename-dpdk-vf':
command => "ip link set ${dpdk_vf_origin_name} name ${dpdk_dev_name}",
unless => "ip link | grep ${dpdk_dev_name}",
} ->
exec { 'set-dpdk-vf-vlan':
command => "ip link set link dev ${contrail::phys_dev} vf ${contrail::dpdk_vf_number} vlan 0"
}
exec { 'set-dpdk-vf-up':
command => "ip link set link dev ${dpdk_dev_name} up",
} ->
exec { 'set-dpdk-vf-spoof':
command => "ip link set link dev ${contrail::phys_dev} vf ${contrail::dpdk_vf_number} spoof off",
}
file {'/etc/udev/rules.d/72-contrail-dpdk-on-vf.rules':
@ -65,16 +56,49 @@ class contrail::compute::network {
}
$interface_config = join(["auto ${dpdk_dev_name}",
"iface ${dpdk_dev_name} inet manual",
"pre-up ip link set link dev ${contrail::phys_dev} vf ${contrail::dpdk_vf_number} vlan 0",
"post-up ip link set link dev ${contrail::phys_dev} vf ${contrail::dpdk_vf_number} spoof off",
],"\n")
"iface ${dpdk_dev_name} inet manual",
"pre-up ip link set link dev ${raw_phys_dev} vf ${contrail::dpdk_vf_number} vlan 0",
"post-up ip link set link dev ${raw_phys_dev} vf ${contrail::dpdk_vf_number} spoof off",
],"\n")
file {"/etc/network/interfaces.d/ifcfg-${dpdk_dev_name}":
ensure => file,
content => $interface_config,
require => File['/etc/udev/rules.d/72-contrail-dpdk-on-vf.rules'],
}
exec { "ifup_${dpdk_dev_name}":
command => "ifup ${dpdk_dev_name}",
unless => "ip link show dev ${dpdk_dev_name} | grep ,UP",
require => File["/etc/network/interfaces.d/ifcfg-${dpdk_dev_name}"],
}
# Add vlan interface config if needed
if ($::contrail::phys_dev != $raw_phys_dev) {
$vlan_interface_config = join([ "auto ${dpdk_dev_name}.${vlan_tag}",
"iface ${dpdk_dev_name}.${vlan_tag} inet manual",
"vlan-raw-device ${dpdk_dev_name}",
],"\n")
file {"/etc/network/interfaces.d/ifcfg-${dpdk_dev_name}.${vlan_tag}":
ensure => file,
content => $vlan_interface_config,
require => [File['/etc/udev/rules.d/72-contrail-dpdk-on-vf.rules'],
File["/etc/network/interfaces.d/ifcfg-${dpdk_dev_name}"],
],
}
exec { "ifup_${dpdk_dev_name}.${vlan_tag}":
command => "ifup ${dpdk_dev_name}.${vlan_tag}",
unless => "ip link show dev ${dpdk_dev_name}.${vlan_tag} | grep ,UP",
require => [File["/etc/network/interfaces.d/ifcfg-${dpdk_dev_name}.${vlan_tag}"],
Exec["ifup_${dpdk_dev_name}"],
],
}
}
}
}

View File

@ -14,9 +14,18 @@
class contrail::compute::vrouter {
$raw_phys_dev = regsubst($::contrail::phys_dev, '\..*' , '')
$vlan_tag = regsubst($::contrail::phys_dev, '^.+\.' , '')
if $contrail::compute_dpdk_on_vf {
$vf_data = get_vf_data($contrail::phys_dev, $contrail::dpdk_vf_number)
$phys_dev = "dpdk-vf${contrail::dpdk_vf_number}"
# Add vlan to phys_dev if needed
if ($::contrail::phys_dev != $raw_phys_dev) {
$phys_dev = "dpdk-vf${contrail::dpdk_vf_number}.${vlan_tag}"
} else {
$phys_dev = "dpdk-vf${contrail::dpdk_vf_number}"
}
$dpdk_dev_pci = $vf_data['vf_pci_addr']
$dev_mac = $vf_data['vf_mac_addr']
} else {
@ -44,7 +53,6 @@ class contrail::compute::vrouter {
}
}
$raw_phys_dev = regsubst($::contrail::phys_dev, '\..*' , '')
# in case of bonds, MAC address should be set permanently, because slave interfaces
# may start in random order during the boot process
if ( 'bond' in $raw_phys_dev) {

View File

@ -27,6 +27,19 @@ class contrail::controller::scheduler {
}
}
if $contrail::settings['dpdk_on_vf'] {
ini_subsetting {'add_pci_passthrough_filter':
ensure => present,
section => 'DEFAULT',
key_val_separator => '=',
path => '/etc/nova/nova.conf',
setting => 'scheduler_default_filters',
subsetting => 'PciPassthroughFilter',
subsetting_separator => ',',
notify => Service['nova-scheduler'],
}
}
Ini_subsetting <||> ~>
service { 'nova-scheduler':
ensure => $ensure,