From 6c7dee608c98247d0474a412e513f1cfdac6d2b2 Mon Sep 17 00:00:00 2001 From: Jon Sherwood Date: Fri, 16 May 2025 13:23:00 -0400 Subject: [PATCH] Add interface name parameter for DPDK configs Implemented parameter 'iface' in the nics dictionaries which allows users to reference the interfaces by name instead of only 'pci_id' in the values.yaml. This can ease the configuration of interfaces that may have differing PCI addresses among the servers. 'pci_id' will take precedence if both are configured. Change-Id: I93248bb580460c48fff01130d80e2bfe31dadf72 --- .../_neutron-openvswitch-agent-init.sh.tpl | 29 ++++++++++++++++--- neutron/values.yaml | 6 ++++ .../notes/neutron-b2247f89a5f258aa.yaml | 11 +++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/neutron-b2247f89a5f258aa.yaml diff --git a/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl b/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl index bd0a64ac81..4facfdc99f 100644 --- a/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl +++ b/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl @@ -196,6 +196,12 @@ function process_dpdk_nics { while IFS= read -r nic; do local port_name=$(get_dpdk_config_value ${nic} '.name') local pci_id=$(get_dpdk_config_value ${nic} '.pci_id') + local iface=$(get_dpdk_config_value ${nic} '.iface') + if [ -n ${iface} ] && [ -z ${pci_id} ]; then + local pci_id=$(get_address_by_nicname ${iface}) + else + iface=$(get_name_by_pci_id "${pci_id}") + fi local bridge=$(get_dpdk_config_value ${nic} '.bridge') local vf_index=$(get_dpdk_config_value ${nic} '.vf_index') @@ -203,8 +209,6 @@ function process_dpdk_nics { migrate_ip "${pci_id}" "${bridge}" fi - iface=$(get_name_by_pci_id "${pci_id}") - if [ -n "${iface}" ]; then ip link set ${iface} promisc on if [ -n "${vf_index}" ]; then @@ -292,6 +296,12 @@ function process_dpdk_bonds { echo $bond | jq -r -c '.nics[]' > /tmp/nics_array while IFS= read -r nic; do local pci_id=$(get_dpdk_config_value ${nic} '.pci_id') + local iface=$(get_dpdk_config_value ${nic} '.iface') + if [ -n ${iface} ] && [ -z ${pci_id} ]; then + local pci_id=$(get_address_by_nicname ${iface}) + else + iface=$(get_name_by_pci_id "${pci_id}") + fi local nic_name=$(get_dpdk_config_value ${nic} '.name') local pmd_rxq_affinity=$(get_dpdk_config_value ${nic} '.pmd_rxq_affinity') local vf_index=$(get_dpdk_config_value ${nic} '.vf_index') @@ -302,8 +312,6 @@ function process_dpdk_bonds { ip_migrated=true fi - iface=$(get_name_by_pci_id "${pci_id}") - if [ -n "${iface}" ]; then ip link set ${iface} promisc on if [ -n "${vf_index}" ]; then @@ -407,6 +415,19 @@ function get_driver_by_address { fi } +function get_address_by_nicname { + if [[ -e /sys/class/net/$1 ]]; then + local pci_address=$(readlink -f /sys/class/net/$1/device | xargs basename) + if [[ -e /sys/bus/pci/devices/${pci_address} ]]; then + echo ${pci_address} + else + echo "PCI id for interface $1 cannot be found" >&2 + fi + else + echo "Interface name $1 cannot be found" >&2 + fi +} + function init_ovs_dpdk_bridge { bridge=$1 ovs-vsctl --db=unix:${OVS_SOCKET} --may-exist add-br ${bridge} \ diff --git a/neutron/values.yaml b/neutron/values.yaml index 1691e00498..2c90e91c89 100644 --- a/neutron/values.yaml +++ b/neutron/values.yaml @@ -2223,6 +2223,9 @@ conf: # must NOT be provided here. nics: - name: dpdk0 + # Optionally, instead of using pci_id you can use the name of + # the interface. If both are used, pci_id has presedence. + # iface: eth0 pci_id: '0000:05:00.0' # Set VF Index in case some particular VF(s) need to be # used with ovs-dpdk. @@ -2265,6 +2268,9 @@ conf: # ovs_options: "bond_mode=active-backup" # nics: # - name: dpdk_b0s0 + # # Optionally, instead of using pci_id you can use the name of + # # the interface. If both are used, pci_id has presedence. + # # iface: eth0 # pci_id: '0000:06:00.0' # pmd_rxq_affinity: "0:3,1:27" # # Set VF Index in case some particular VF(s) need to be diff --git a/releasenotes/notes/neutron-b2247f89a5f258aa.yaml b/releasenotes/notes/neutron-b2247f89a5f258aa.yaml new file mode 100644 index 0000000000..4b3d180654 --- /dev/null +++ b/releasenotes/notes/neutron-b2247f89a5f258aa.yaml @@ -0,0 +1,11 @@ +--- +# To create a new release note related to a specific chart: +# reno new +# +# To create a new release note for a common change (when multiple charts +# are changed): +# reno new common +neutron: + - | + Add interface name parameter for DPDK configs +...