Provide pci whitelist for the DPDK_OPTIONS for ovs
To use DPDK, nics has to be bind with DPDK drivers. Once binded, the nics will not be listed in the kernel commands. We have to update the list of PCI address of the nics which are bound to the DPDK drivers with openvswtich DPDK_OPTIONS as whitelist. For which, the list of PCI address of the nics which are bound to the given DPDK drivers are listed via a custom facter. This whitelist is fed as input to the DPDK_OPTIONS. Co-Authored-By: Jaganathan Palanisamy <jpalanis@redhat.com> Implements: blueprint tripleo-ovs-dpdk Change-Id: I4fbca23e07468ee58dfce10a6deaf2f25da654c7
This commit is contained in:
parent
f1c5e34409
commit
0f93b8926e
28
lib/facter/pci_address.rb
Normal file
28
lib/facter/pci_address.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require 'facter'
|
||||
drivers_details=Facter::Util::Resolution.exec("cat /proc/bus/pci/devices")
|
||||
drivers_lines=drivers_details.split("\n")
|
||||
drivers=Hash.new
|
||||
drivers_lines.each do |line|
|
||||
line = line.gsub(/^\s+|\s+$/m, '').split(" ")
|
||||
if line.length == 18
|
||||
pci_embed = line[0]
|
||||
driver = line[-1]
|
||||
bus = pci_embed[0] + pci_embed[1]
|
||||
dev = ((pci_embed[2].to_i(16) << 1) + (pci_embed[3].to_i(16) >> 3)).to_s(16).upcase
|
||||
fun = (pci_embed[3].to_i(16) & 7).to_s(16).upcase
|
||||
pci = "0000:" + bus + ":" + dev + "." + fun
|
||||
if not drivers.has_key?(driver)
|
||||
drivers[driver] = Array.new
|
||||
end
|
||||
drivers[driver] << pci
|
||||
end
|
||||
end
|
||||
|
||||
drivers.each do |driver,pci_addr|
|
||||
Facter.add("pci_address_driver_#{driver}") do
|
||||
confine :kernel => :linux
|
||||
setcode do
|
||||
pci_addr.join(',')
|
||||
end
|
||||
end
|
||||
end
|
@ -3,10 +3,6 @@
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) State of the openvswitch package
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*core_list*]
|
||||
# (required) The list of cores to be used by the DPDK Poll Mode Driver
|
||||
# The core_list is a string with format as <c1>[-c2][,c3[-c4],...] where c1, c2, etc are core indexes between 0 and 128
|
||||
@ -15,17 +11,26 @@
|
||||
# [*memory_channels*]
|
||||
# (required) The number of memory channels to use as an integer
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) State of the openvswitch package
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*socket_mem*]
|
||||
# (Optional) Set the memory to be allocated on each socket
|
||||
# The socket_mem is a string with comma separated memory list in MB in the order of socket numbers.
|
||||
# For example, to allocate memory of 1GB for socket 1 and no allocation for socket 0, the value should be "0,1024"
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*driver_type*]
|
||||
# (Optional) The DPDK Driver type
|
||||
# Defaults to 'vfio-pci'
|
||||
#
|
||||
class vswitch::dpdk (
|
||||
$core_list,
|
||||
$memory_channels,
|
||||
$package_ensure = 'present',
|
||||
$socket_mem = undef,
|
||||
$driver_type = 'vfio-pci',
|
||||
) {
|
||||
|
||||
include ::vswitch::params
|
||||
@ -41,7 +46,14 @@ class vswitch::dpdk (
|
||||
$socket_string = "--socket-mem ${socket_mem}"
|
||||
}
|
||||
|
||||
$options = "DPDK_OPTIONS = \"-l ${core_list} -n ${memory_channels} ${socket_string}\""
|
||||
if $driver_type {
|
||||
$pci_list = inline_template('<%= Facter.value("pci_address_driver_#@driver_type") %>')
|
||||
unless empty($pci_list) {
|
||||
$white_list = inline_template('-w <%= @pci_list.gsub(",", " -w ") %>')
|
||||
}
|
||||
}
|
||||
|
||||
$options = "DPDK_OPTIONS = \"-l ${core_list} -n ${memory_channels} ${socket_string} ${white_list}\""
|
||||
|
||||
case $::osfamily {
|
||||
'Redhat': {
|
||||
|
3
releasenotes/notes/ovs-dpdk-97916bffadb9d594.yaml
Normal file
3
releasenotes/notes/ovs-dpdk-97916bffadb9d594.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
features:
|
||||
- DPDK puppet class is added to configure DPDK with ovs.
|
@ -3,17 +3,9 @@ require 'spec_helper'
|
||||
describe 'vswitch::dpdk' do
|
||||
|
||||
let :default_params do {
|
||||
:package_ensure => 'present',
|
||||
:core_list => '1,2',
|
||||
:memory_channels => '2'
|
||||
}
|
||||
end
|
||||
|
||||
let :socket_mem_params do {
|
||||
:package_ensure => 'present',
|
||||
:core_list => '1,2',
|
||||
:memory_channels => '2',
|
||||
:socket_mem => '1024'
|
||||
}
|
||||
end
|
||||
|
||||
@ -47,7 +39,6 @@ describe 'vswitch::dpdk' do
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'vswitch dpdk mandatory params' do
|
||||
@ -55,20 +46,39 @@ describe 'vswitch::dpdk' do
|
||||
is_expected.to contain_file_line('/etc/sysconfig/openvswitch').with(
|
||||
:path => '/etc/sysconfig/openvswitch',
|
||||
:match => '^DPDK_OPTIONS.*',
|
||||
:line => 'DPDK_OPTIONS = "-l 1,2 -n 2 "',
|
||||
:line => 'DPDK_OPTIONS = "-l 1,2 -n 2 "',
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'vswitch dpdk socket_mem param' do
|
||||
it 'configures dpdk options for ovs' do
|
||||
is_expected.to contain_file_line('/etc/sysconfig/openvswitch').with(
|
||||
:path => '/etc/sysconfig/openvswitch',
|
||||
:match => '^DPDK_OPTIONS.*',
|
||||
:line => 'DPDK_OPTIONS = "-l 1,2 -n 2 --socket-mem 1024"',
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
shared_examples_for 'vswitch dpdk additional params' do
|
||||
context 'when passing socket mem' do
|
||||
before :each do
|
||||
params.merge!(:socket_mem => '1024')
|
||||
end
|
||||
it 'configures dpdk options with socket memory' do
|
||||
is_expected.to contain_file_line('/etc/sysconfig/openvswitch').with(
|
||||
:path => '/etc/sysconfig/openvswitch',
|
||||
:match => '^DPDK_OPTIONS.*',
|
||||
:line => 'DPDK_OPTIONS = "-l 1,2 -n 2 --socket-mem 1024 "',
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when providing valid driver type facts' do
|
||||
before :each do
|
||||
params.merge!(:driver_type => 'test')
|
||||
end
|
||||
it 'configures dpdk options with pci address for driver test' do
|
||||
is_expected.to contain_file_line('/etc/sysconfig/openvswitch').with(
|
||||
:path => '/etc/sysconfig/openvswitch',
|
||||
:match => '^DPDK_OPTIONS.*',
|
||||
:line => 'DPDK_OPTIONS = "-l 1,2 -n 2 -w 0000:00:05.0 -w 0000:00:05.1"',
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -89,19 +99,20 @@ describe 'vswitch::dpdk' do
|
||||
end
|
||||
|
||||
context 'on redhat with additonal parameters' do
|
||||
let :params do socket_mem_params end
|
||||
let :params do default_params end
|
||||
|
||||
let :facts do
|
||||
OSDefaults.get_facts({
|
||||
:osfamily => 'Redhat',
|
||||
:ovs_version => '1.4.2',
|
||||
:pci_address_driver_test => '0000:00:05.0,0000:00:05.1'
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do redhat_platform_params end
|
||||
|
||||
it_configures 'vswitch dpdk'
|
||||
it_configures 'vswitch dpdk socket_mem param'
|
||||
it_configures 'vswitch dpdk additional params'
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user