Skip to content

Commit

Permalink
Allow additional dpdk runtime libraries to be installed
Browse files Browse the repository at this point in the history
Only some dpdk runtime libraries are installed by default, but some
environments may need additional libraries installed. This adds an
option to allow the user to specify additional dpdk runtime libraries
via a config option `dpdk-runtime-libraries`.

Closes-Bug: #1936850
  • Loading branch information
wolsen committed Feb 9, 2022
1 parent f0a6c62 commit f98d88b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
15 changes: 15 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ options:
uio_pci_generic
.
Only used when DPDK is enabled.
dpdk-runtime-libraries:
type: string
default:
description: |
Space delimited list of additional DPDK runtime libraries that should
be installed when DPDK is enabled.
.
By default, only the runtime libraries that are recommended with the
dpdk libraries are installed. Environments that need additional libraries
installed should include those library packages. For example, to enable
the pmd-bnx2x runtime library specify the name of the software package
`librte-pmd-bnx2x20.0`. To enable the pmd-bnx2x and the pmd-ice runtime
libraries, specify the value as `librte-pmd-bnx2x20.0 librte-pmd-ice20.0`.
.
Only used when DPDK is enabled.
enable-hardware-offload:
type: boolean
default: false
Expand Down
16 changes: 16 additions & 0 deletions lib/charms/ovn_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ def enable_openstack(self):
"""
return reactive.is_flag_set('charm.ovn-chassis.enable-openstack')

@property
def additional_dpdk_libraries(self):
"""A list of additional runtime libraries to be installed for dpdk.
:returns: list of additional packages to install
:rtype: List[str]
"""
if self.options.enable_dpdk and self.options.dpdk_runtime_libraries:
# dpdk_runtime_libraries is a space delimited list of strings.
# some options are disabled by passing 'None' so filter out a
# specifying of a 'None' value
return list(filter(lambda x: x and x.lower() != 'none',
self.options.dpdk_runtime_libraries.split()))
return []

@property
def packages(self):
"""Full list of packages to be installed.
Expand All @@ -310,6 +325,7 @@ def packages(self):
_packages = ['ovn-host']
if self.options.enable_dpdk:
_packages.extend(['openvswitch-switch-dpdk'])
_packages.extend(self.additional_dpdk_libraries)
if self.options.enable_hardware_offload or self.options.enable_sriov:
# The ``sriov-netplan-shim`` package does boot-time
# configuration of Virtual Functions (VFs) in the system.
Expand Down
22 changes: 22 additions & 0 deletions unit_tests/test_lib_charms_ovn_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,27 @@ def test_optional_openstack_metadata_wallaby(self):
'neutron-ovn-metadata-agent'])


class TestDPDKOVNChassisCharmExtraLibs(Helper):

def setUp(self):
super().setUp(config={
'enable-hardware-offload': False,
'enable-sriov': False,
'enable-dpdk': True,
'dpdk-bond-mappings': ('dpdk-bond0:a0:36:9f:dd:37:a4 '
'dpdk-bond0:a0:36:9f:dd:3e:9c'),
'bridge-interface-mappings': 'br-ex:eth0 br-data:dpdk-bond0',
'ovn-bridge-mappings': (
'provider:br-ex other:br-data'),
'prefer-chassis-as-gw': False,
'dpdk-runtime-libraries': 'librte-pmd-hinic20.0 None',
})

def test__init__(self):
self.assertEquals(self.target.packages, [
'ovn-host', 'openvswitch-switch-dpdk', 'librte-pmd-hinic20.0'])


class TestDPDKOVNChassisCharm(Helper):

def setUp(self):
Expand All @@ -455,6 +476,7 @@ def setUp(self):
'ovn-bridge-mappings': (
'provider:br-ex other:br-data'),
'prefer-chassis-as-gw': False,
'dpdk-runtime-libraries': '',
})

def test__init__(self):
Expand Down

0 comments on commit f98d88b

Please sign in to comment.