From 06c2b3849b614bf3f2af82c3a891dea8f3c85b33 Mon Sep 17 00:00:00 2001 From: tsurendra Date: Fri, 25 Mar 2016 12:12:43 -0700 Subject: [PATCH] Closes-Bug: #1546725 SM: Need to have support for SROIV provisioning Support SRIOV provisioning in SM. Testing: Provisioned and testbed by launching a SRIOV VM and seeing the vland id for the VF interface. Change-Id: I42b9140d163950ac48e5c49268d1ae676e906b17 --- .../contrail/manifests/compute/config.pp | 11 +++++ .../modules/contrail/manifests/init.pp | 6 ++- .../lib/setup_passthrough_white_list.pp | 38 +++++++++++++++++ .../contrail/manifests/lib/setup_sriov.pp | 19 +++++++++ .../manifests/lib/setup_sriov_wrapper.pp | 42 +++++++++++++++++++ .../modules/contrail/manifests/params.pp | 2 + .../openstack/manifests/common/nova.pp | 22 ++++++++++ 7 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 contrail/environment/modules/contrail/manifests/lib/setup_passthrough_white_list.pp create mode 100644 contrail/environment/modules/contrail/manifests/lib/setup_sriov.pp create mode 100644 contrail/environment/modules/contrail/manifests/lib/setup_sriov_wrapper.pp diff --git a/contrail/environment/modules/contrail/manifests/compute/config.pp b/contrail/environment/modules/contrail/manifests/compute/config.pp index 2d17fa96..f0016219 100644 --- a/contrail/environment/modules/contrail/manifests/compute/config.pp +++ b/contrail/environment/modules/contrail/manifests/compute/config.pp @@ -40,6 +40,7 @@ $xmpp_dns_auth_enable = $::contrail::params::xmpp_dns_auth_enable, $enable_dpdk= $::contrail::params::enable_dpdk, $contrail_rabbit_servers = $::contrail::params::contrail_rabbit_servers, + $sriov = $::contrail::params::sriov, ) { $config_ip_to_use = $::contrail::params::config_ip_to_use $keystone_ip_to_use = $::contrail::params::keystone_ip_to_use @@ -328,6 +329,16 @@ } } + + notify { "sriov = ${sriov}":; } + $sriov_keys = keys($sriov) + if (!empty($sriov)) { + contrail::lib::setup_sriov_wrapper {$sriov_keys: + intf_hash => $sriov, + enable_dpdk => $enable_dpdk, + } + } + contrail_vrouter_agent_config { 'DEFAULT/xmpp_auth_enable' : value => "$xmpp_auth_enable"; 'DEFAULT/xmpp_server_cert' : value => "/etc/contrail/ssl/certs/server.pem"; diff --git a/contrail/environment/modules/contrail/manifests/init.pp b/contrail/environment/modules/contrail/manifests/init.pp index 3a1e27a7..85618dc2 100644 --- a/contrail/environment/modules/contrail/manifests/init.pp +++ b/contrail/environment/modules/contrail/manifests/init.pp @@ -694,6 +694,8 @@ $contrail_amqp_port = '', $openstack_amqp_ip_list = '', $openstack_amqp_port = '', + $sriov = {}, + $sriov_enable = false, ) { class { '::contrail::params': # Common Parameters @@ -778,6 +780,8 @@ contrail_amqp_port => hiera(openstack::contrail_amqp_port, hiera(contrail::params::contrail_amqp_port, $contrail_amqp_port)), openstack_amqp_ip_list => hiera(openstack::openstack_amqp_ip_list, hiera(contrail::params::openstack_amqp_ip_list, $openstack_amqp_ip_list)), openstack_amqp_port => hiera(openstack::openstack_amqp_port, hiera(contrail::params::openstack_amqp_port, $openstack_amqp_port)), + sriov_enable => hiera(contrail::openstack::sriov::enable, hiera(contrail::params::sriov_enable, $sriov_enable)), + # Openstack HA Parameters internal_vip => hiera(openstack::ha::internal_vip, hiera(contrail::params::internal_vip, $internal_vip)), external_vip => hiera(openstack::ha::external_vip, hiera(contrail::params::external_vip, $external_vip)), @@ -804,7 +808,7 @@ compute_passwd_list => hiera(contrail::compute::compute_passwd_list, hiera(contrail::params::compute_passwd_list, $compute_passwd_list)), huge_pages => hiera(contrail::compute::dpdk::huge_pages, hiera(contrail::params::huge_pages, $huge_pages)), core_mask => hiera(contrail::compute::dpdk::core_mask, hiera(contrail::params::core_mask, $core_mask)), - + sriov => hiera(contrail::compute::sriov,hiera(contrail::params::sriov, $sriov)), # VMWare Parameters vmware_ip => hiera(contrail::vmware::vmware_ip, hiera(contrail::params::vmware_ip, $vmware_ip)), vmware_username => hiera(contrail::vmware::vmware_username, hiera(contrail::params::vmware_username, $vmware_username)), diff --git a/contrail/environment/modules/contrail/manifests/lib/setup_passthrough_white_list.pp b/contrail/environment/modules/contrail/manifests/lib/setup_passthrough_white_list.pp new file mode 100644 index 00000000..64c8929d --- /dev/null +++ b/contrail/environment/modules/contrail/manifests/lib/setup_passthrough_white_list.pp @@ -0,0 +1,38 @@ +define contrail::lib::setup_passthrough_white_list( + $dev_name, +) { + $physnet = $title + + notify { "phys_nets_${title} = ${physnet}":; } + notify { "dev_name_${title} = ${dev_name}":; } + $wl = "{ \"devname\": \"${dev_name}\", \"physical_network\": \"${physnet}\"}" + $pci_passthrough_whitelist_line = "pci_passthrough_whitelist = ${wl}" + notify { "wl_${title}=${wl}":; } + notify { "pci_passthrough_whitellist_line_${title}=${pci_passthrough_whitelist_line}":; } + exec { "config_pci_whitelist_${title}": + command => "sed -i '/\[DEFAULT\]/a ${pci_passthrough_whitelist_line} ' /etc/nova/nova.conf", + provider => shell, + logoutput => true + } + + +/* + file_line { "config_pci_whitelist_${title}": + path => '/etc/nova/nova.conf', + line => "pci_passthrough_whitelist = ${wl}" + } + #cannot use openstack-config as multi-valued option is not supported + #Also cannot use nova_config resourse as it is seen as a re-declaration by puppet + exec { "config_pci_whitelist_${title}": + command => "openstack-config --set /etc/nova/nova.conf DEFAULT pci_passthrough_whitelist ${wl}", + provider => shell, + logoutput => true + } + + $nova_pci_passthrough_whitelist_params = { + 'pci_passthrough_whitelist' => { value => '{ "devname": $dev_name, "physical_network": $physnet}'} + } + + create_resources(nova_config, $nova_pci_passthrough_whitelist_params, {}) +*/ +} diff --git a/contrail/environment/modules/contrail/manifests/lib/setup_sriov.pp b/contrail/environment/modules/contrail/manifests/lib/setup_sriov.pp new file mode 100644 index 00000000..21e07aca --- /dev/null +++ b/contrail/environment/modules/contrail/manifests/lib/setup_sriov.pp @@ -0,0 +1,19 @@ +define contrail::lib::setup_sriov( + $intf_name, + $num_of_vfs, + $physnet_list, +) { + $line = "echo ${num_of_vfs} > /sys/class/net/${intf_name}/device/sriov_numvfs" + exec { "setup_rc_local_${title}": + command => "sed -i '/exit 0/i ${line}' /etc/rc.local", + provider => shell, + logoutput => true, + } + + + + contrail::lib::setup_passthrough_white_list{ $physnet_list: + dev_name => $intf_name } + + +} diff --git a/contrail/environment/modules/contrail/manifests/lib/setup_sriov_wrapper.pp b/contrail/environment/modules/contrail/manifests/lib/setup_sriov_wrapper.pp new file mode 100644 index 00000000..542866ce --- /dev/null +++ b/contrail/environment/modules/contrail/manifests/lib/setup_sriov_wrapper.pp @@ -0,0 +1,42 @@ +define contrail::lib::setup_sriov_wrapper( + $intf_hash, + $enable_dpdk, +) { + + if ($enablle_dpdk){ + $linux_default_val = "nomdmonddf nomdmonisw intel_iommu=pt" + } else { + $linux_default_val = "nomdmonddf nomdmonisw intel_iommu=on" + } + + + if (!empty($intf_hash)) { + $intf_details = $intf_hash[$title] + if ($intf_hash) { + file_line { "set_grub_iommu_${title}": + path => '/etc/default/grub', + line => "GRUB_CMDLINE_LINUX_DEFAULT=\"${linux_default_val}\"", + match => '^GRUB_CMDLINE_LINUX_DEFAULT.*', + } +/* + -> + exec { "setup_default": + command => "echo '[DEFAULT]' >> /etc/nova/nova.conf", + provider => shell, + logoutput => true, + } +*/ + + } + + notify { "intf_hash_${title} = ${intf_hash}":; } + notify { "title_${title} = ${title}":; } + notify { "intf_details_${title} = ${intf_details}":; } + contrail::lib::setup_sriov{$title : + intf_name => $title, + num_of_vfs => $intf_details['VF'], + physnet_list => $intf_details['physnets'] + } + + } +} diff --git a/contrail/environment/modules/contrail/manifests/params.pp b/contrail/environment/modules/contrail/manifests/params.pp index 3c0d686b..39f55417 100644 --- a/contrail/environment/modules/contrail/manifests/params.pp +++ b/contrail/environment/modules/contrail/manifests/params.pp @@ -693,6 +693,8 @@ $contrail_amqp_port, $openstack_amqp_ip_list, $openstack_amqp_port, + $sriov, + $sriov_enable, ) { if (($contrail_internal_vip != '') or ($internal_vip != '') or diff --git a/contrail/environment/modules/openstack/manifests/common/nova.pp b/contrail/environment/modules/openstack/manifests/common/nova.pp index 6259203b..abb8f9a7 100644 --- a/contrail/environment/modules/openstack/manifests/common/nova.pp +++ b/contrail/environment/modules/openstack/manifests/common/nova.pp @@ -20,6 +20,8 @@ $contrail_neutron_server = $::contrail::params::config_ip_to_use $openstack_ip_list = $::contrail::params::openstack_ip_list + + $sriov_enable = $::contrail::params::sriov_enable $contrail_memcache_servers = inline_template('<%= @openstack_ip_list.map{ |ip| "#{ip}:11211" }.join(",") %>') nova_config { 'DEFAULT/default_floating_pool': value => 'public' } @@ -161,4 +163,24 @@ } } + notify { "sriov = ${sriov}":; } + if ($sriov_enable) { + file_line_after { + 'scheduler_default_filters': + line => + 'scheduler_default_filters=PciPassthroughFilter', + path => '/etc/nova/nova.conf', + after => '^\s*\[DEFAULT\]'; + 'scheduler_available_filters': + line => 'scheduler_available_filters=nova.scheduler.filters.pci_passthrough_filter.PciPassthroughFilter', + path => '/etc/nova/nova.conf', + after => '^\s*\[DEFAULT\]'; + 'scheduler_available_filters2': + line => 'scheduler_available_filters=nova.scheduler.filters.all_filters', + path => '/etc/nova/nova.conf', + after => '^\s*\[DEFAULT\]'; + + } + } + }