From b28edfb2a7697ad5f5990b39d2e4c90dee558b05 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Fri, 30 Dec 2016 02:43:03 +0400 Subject: [PATCH] Configure number of multiq for dpdk Change-Id: I34781a752fba5cc35cbe4190619a8869d07c4993 Closes-Bug: 1643920 Depends-On: I9b3160b7e0659d11445ca3927aa38e523a93b3a9 --- .../puppet/l23network/files/debian_ovsdpdk | 9 ++++++-- .../l23_stored_config/dpdkovs_ubuntu.rb | 14 +++++++++++++ .../dpdkovs_ubuntu__spec/ifcfg-bond_lacp | 3 ++- .../dpdkovs_ubuntu__spec/ifcfg-enp1s0f0 | 3 ++- .../dpdkovs_ubuntu__bond__spec.rb | 21 +++++++++++++++++-- .../dpdkovs_ubuntu__port__spec.rb | 9 ++++++-- 6 files changed, 51 insertions(+), 8 deletions(-) diff --git a/deployment/puppet/l23network/files/debian_ovsdpdk b/deployment/puppet/l23network/files/debian_ovsdpdk index 15ba357765..87fe5d0f79 100644 --- a/deployment/puppet/l23network/files/debian_ovsdpdk +++ b/deployment/puppet/l23network/files/debian_ovsdpdk @@ -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} \ diff --git a/deployment/puppet/l23network/lib/puppet/provider/l23_stored_config/dpdkovs_ubuntu.rb b/deployment/puppet/l23network/lib/puppet/provider/l23_stored_config/dpdkovs_ubuntu.rb index e44d26db6a..fab0846d6c 100644 --- a/deployment/puppet/l23network/lib/puppet/provider/l23_stored_config/dpdkovs_ubuntu.rb +++ b/deployment/puppet/l23network/lib/puppet/provider/l23_stored_config/dpdkovs_ubuntu.rb @@ -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 diff --git a/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-bond_lacp b/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-bond_lacp index 6987f99a8d..c8f0b990a5 100644 --- a/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-bond_lacp +++ b/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-bond_lacp @@ -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 \ No newline at end of file + 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 diff --git a/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-enp1s0f0 b/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-enp1s0f0 index 99b9083f10..b3551b0a8d 100644 --- a/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-enp1s0f0 +++ b/deployment/puppet/l23network/spec/fixtures/provider/l23_stored_config/dpdkovs_ubuntu__spec/ifcfg-enp1s0f0 @@ -2,4 +2,5 @@ allow-br-prv enp1s0f0 iface enp1s0f0 inet manual ovs_type DPDKOVSPort dpdk_port dpdk0 -ovs_bridge br-prv \ No newline at end of file +ovs_bridge br-prv +multiq_threads 3 diff --git a/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__bond__spec.rb b/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__bond__spec.rb index ea286c3015..ce3d201057 100644 --- a/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__bond__spec.rb +++ b/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__bond__spec.rb @@ -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 \ No newline at end of file +end diff --git a/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__port__spec.rb b/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__port__spec.rb index 98d68e497d..26f207c619 100644 --- a/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__port__spec.rb +++ b/deployment/puppet/l23network/spec/unit/puppet/provider/l23_stored_config/dpdkovs_ubuntu__port__spec.rb @@ -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 \ No newline at end of file +end