Configure number of multiq for dpdk

Change-Id: I34781a752fba5cc35cbe4190619a8869d07c4993
Closes-Bug: 1643920
Depends-On: I9b3160b7e0659d11445ca3927aa38e523a93b3a9
This commit is contained in:
Mikhail 2016-12-30 02:43:03 +04:00
parent 4f691b399f
commit b28edfb2a7
6 changed files with 51 additions and 8 deletions

View File

@ -31,15 +31,20 @@ if [ "${MODE}" = "start" ]; then
case "${IF_OVS_TYPE}" in
DPDKOVSPort)
DPDK_EXTRA="-- set Interface ${IF_DPDK_PORT} type=dpdk"
if [ -n "$IF_MULTIQ_THREADS" ]; then
DPDK_EXTRA="${DPDK_EXTRA} -- set Interface ${IF_DPDK_PORT} options:n_rxq=${IF_MULTIQ_THREADS}"
fi
ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
"${IF_DPDK_PORT}" ${IF_OVS_OPTIONS} \
${DPDK_EXTRA} \
${OVS_EXTRA+-- $OVS_EXTRA}
;;
DPDKOVSBond)
for slave in ${IF_OVS_BONDS}
do
for slave in ${IF_OVS_BONDS}; do
DPDK_EXTRA="${DPDK_EXTRA} -- set Interface ${slave} type=dpdk"
if [ -n "$IF_MULTIQ_THREADS" ]; then
DPDK_EXTRA="${DPDK_EXTRA} -- set Interface ${slave} options:n_rxq=${IF_MULTIQ_THREADS}"
fi
done
ovs_vsctl -- --fake-iface add-bond "${IF_OVS_BRIDGE}"\
"${IFACE}" ${IF_OVS_BONDS} ${IF_OVS_OPTIONS} \

View File

@ -14,6 +14,10 @@ Puppet::Type.type(:l23_stored_config).provide(:dpdkovs_ubuntu, :parent => Puppet
L23network.get_dpdk_ports_mapping
end
def self.get_config
L23network::Scheme.get_config(Facter.value(:l3_fqdn_hostname))
end
def self.check_if_provider(if_data)
if if_data[:if_type] =~ /dpdkovsport/
if_data[:if_type] = "ethernet"
@ -48,6 +52,7 @@ Puppet::Type.type(:l23_stored_config).provide(:dpdkovs_ubuntu, :parent => Puppet
:bond_ad_select => '',
:bond_updelay => 'ovs_options',
:bond_downdelay => 'ovs_options',
:multiq_threads => 'multiq_threads',
)
end
@ -122,6 +127,15 @@ Puppet::Type.type(:l23_stored_config).provide(:dpdkovs_ubuntu, :parent => Puppet
dpdk_port = dpdk_ports[self.name]
end
def multiq_threads
if self.if_type.to_s == 'bond'
cfg = self.class.get_config
multiq_threads = self.bond_slaves.map { |iface| cfg[:interfaces][iface.to_sym][:vendor_specific][:max_queues]}.min
else
multiq_threads = self.vendor_specific['max_queues']
end
end
def self.mangle__bond_slaves(val)
ports_dpdk_mapping = self.get_dpdk_ports_mapping.invert
val.split(/[\s,]+/).map {|i| ports_dpdk_mapping[i]}.sort

View File

@ -10,4 +10,5 @@ iface bond_lacp inet manual
ovs_bonds dpdk0 dpdk1
ovs_type DPDKOVSBond
ovs_bridge br-prv
ovs_options bond_mode=balance-tcp bond_updelay=111 bond_downdelay=222 lacp=active other_config:lacp-time=fast other_config:bond-miimon-interval=50
ovs_options bond_mode=balance-tcp bond_updelay=111 bond_downdelay=222 lacp=active other_config:lacp-time=fast other_config:bond-miimon-interval=50
multiq_threads 3

View File

@ -2,4 +2,5 @@ allow-br-prv enp1s0f0
iface enp1s0f0 inet manual
ovs_type DPDKOVSPort
dpdk_port dpdk0
ovs_bridge br-prv
ovs_bridge br-prv
multiq_threads 3

View File

@ -25,6 +25,20 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
}
}
let(:config) {
{:interfaces =>
{:enp1s0f0 =>
{:vendor_specific =>
{:max_queues => 3}
},
:enp1s0f1 =>
{:vendor_specific =>
{:max_queues => 3}
}
}
}
}
let(:dpdk_ports_mapping) {
{
'enp1s0f0' => 'dpdk0',
@ -79,6 +93,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
subject { providers[:bond_lacp] }
let(:cfg_file) do
subject.class.stubs(:get_dpdk_ports_mapping).returns(dpdk_ports_mapping)
subject.class.stubs(:get_config).returns(config)
subject.class.format_file('filepath', [subject])
end
it { expect(cfg_file).not_to match(/auto\s+bond_lacp/) }
@ -95,7 +110,8 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
it { expect(cfg_file).to match(/ovs_options.+bond_updelay=111/) }
it { expect(cfg_file).to match(/ovs_options.+bond_downdelay=222/) }
it { expect(cfg_file).to match(/ovs_options.+lacp=active/) }
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(7) } # no more lines in the interface file
it { expect(cfg_file).to match(/multiq_threads\s+3/) }
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(8) } # no more lines in the interface file
end
context "parse data from fixture" do
@ -115,6 +131,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
it { expect(res[:bond_updelay]).to eq '111' }
it { expect(res[:bond_downdelay]).to eq '222' }
it { expect(res[:bond_slaves]).to eq ['enp1s0f0', 'enp1s0f1'] }
it { expect(res[:multiq_threads].to_s).to eq '3' }
end
end
end
end

View File

@ -8,6 +8,9 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
:if_type => 'ethernet',
:bridge => 'br-prv',
:provider => 'dpdkovs_ubuntu',
:vendor_specific => {
:max_queues => 3
},
},
}
}
@ -71,7 +74,8 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
it { expect(cfg_file).to match(/ovs_type\s+DPDKOVSPort/) }
it { expect(cfg_file).to match(/ovs_bridge\s+br-prv/) }
it { expect(cfg_file).to match(/dpdk_port\s+dpdk0/) }
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(5) }
it { expect(cfg_file).to match(/multiq_threads\s+3/) }
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(6) }
end
end
@ -83,6 +87,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
it { expect(res[:bridge]).to eq "br-prv" }
it { expect(res[:if_provider].to_s).to eq 'dpdkovs' }
it { expect(res[:dpdk_port].to_s).to eq 'dpdk0' }
it { expect(res[:multiq_threads].to_s).to eq '3' }
end
end
end
end