Skip to content

Commit

Permalink
Merge pull request #328 from Jaganathancse/ovn_dpdk_config_changes
Browse files Browse the repository at this point in the history
NFV OvS DPDK Configuration Changes
  • Loading branch information
openshift-merge-bot[bot] authored Nov 22, 2023
2 parents 804d7af + 1bee17b commit 8205f7f
Show file tree
Hide file tree
Showing 13 changed files with 541 additions and 1 deletion.
29 changes: 29 additions & 0 deletions docs/source/roles/role-edpm_ovn_dpdk.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
========================
Role - edpm_ovs_dpdk
========================

Usage
~~~~~

This Ansible role allows to do the following tasks:

* Configure the required OvS DPDK configuration
based on the OvS DPDK edpm ansible variables.

* Remove any existing OvS DPDK configuration based
on the OvS DPDK edpm ansible variables.

Here is an example of a playbook:

.. code-block:: YAML
- name: "Configure OvS DPDK Configs"
include_role:
name: "osp.edpm.edpm_ovs_dpdk"
vars:
edpm_ovs_dpdk_pmd_core_list: "1,13,3,15"
edpm_ovs_dpdk_lcore_list: "0,12"
edpm_ovs_dpdk_socket_memory: "4096"
edpm_ovs_dpdk_memory_channels: 4
edpm_ovs_dpdk_vhost_postcopy_support: tru
edpm_nova_libvirt_vhostuser_socket_group: 'hugetlbfs'
12 changes: 12 additions & 0 deletions playbooks/configure_ovs_dpdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Configure OvS DPDK
hosts: all
strategy: linear
become: true
tasks:
- name: Configure OvS DPDK configs
ansible.builtin.import_role:
name: osp.edpm.edpm_ovs_dpdk
tags:
- edpm_ovs_dpdk
16 changes: 16 additions & 0 deletions plugins/filter/cpu_mask.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

DOCUMENTATION:
name: cpu_mask
author: "EDPM team"
version_added: 2.9
short_description: Calculates cpu mask for the list of CPus.
description: |
This filter will take the list of CPUs and will convert
that to a cpu mask value.
EXAMPLES: |
"{{ cpu_list | osp.edpm.cpu_mask }}"
RETURN:
_value:
description:
type: string
31 changes: 30 additions & 1 deletion plugins/filter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# under the License.

import ast
import binascii
import json
import re

Expand All @@ -25,7 +26,8 @@ def filters(self):
'needs_delete': self.needs_delete,
'haskey': self.haskey,
'dict_to_list': self.dict_to_list,
'jump_chain_targets': self.jump_chain_targets
'jump_chain_targets': self.jump_chain_targets,
'cpu_mask': self.cpu_mask
}

def needs_delete(self, container_infos, config, config_id,
Expand Down Expand Up @@ -190,3 +192,30 @@ def _filter(item):
if 'target' in target.get('jump', {}).keys():
targets.append(target['jump']['target'])
return targets

def cpu_mask(self, cpu_list):
"""Return a cpu mask for the list of CPUs.
Example - for input of 1,13 the mask would be 2002
:param cpu_list: list
:returns: cpu mask
"""
mask = 0
cpus = []
for cpu in cpu_list.split(','):
if '-' in cpu:
rng = cpu.split('-')
cpus.extend(range(int(rng[0]), int(rng[1]) + 1))
else:
cpus.append(int(cpu))
cpus.sort()
max_val = int(cpus[-1])
byte_arr = bytearray(int(max_val / 8) + 1)

for item in cpus:
pos = int(int(item) / 8)
bit = int(item) % 8
byte_arr[pos] |= 2**bit

byte_arr.reverse()
mask = binascii.hexlify(byte_arr)
return mask.decode("utf-8").lstrip("0")
35 changes: 35 additions & 0 deletions roles/edpm_ovs_dpdk/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# Copyright 2023 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


# All variables intended for modification should be placed in this file.

# All variables within this role should have a prefix of "edpm_ovs_dpdk"
edpm_ovs_dpdk_pmd_core_list: ""
edpm_ovs_dpdk_lcore_list: ""
edpm_ovs_dpdk_memory_channels: 4
edpm_ovs_dpdk_extra: ""
edpm_ovs_dpdk_socket_memory: ""
edpm_ovs_dpdk_revalidator_cores: ""
edpm_ovs_dpdk_handler_cores: ""
edpm_ovs_dpdk_emc_insertion_probablity: ""
edpm_ovs_dpdk_enable_tso: false
edpm_ovs_dpdk_pmd_auto_lb: false
edpm_ovs_dpdk_pmd_load_threshold: ""
edpm_ovs_dpdk_pmd_improvement_threshold: ""
edpm_ovs_dpdk_pmd_rebal_interval: ""
edpm_ovs_dpdk_vhost_postcopy_support: false
edpm_ovs_dpdk_vhost_postcopy_ovs_options: "--mlockall=no"
66 changes: 66 additions & 0 deletions roles/edpm_ovs_dpdk/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
argument_specs:
# ./roles/edpm_ovs_dpdk/tasks/main.yml entry point
main:
short_description: The main entry point for the edpm_ovs_dpdk role.
options:
edpm_ovs_dpdk_pmd_core_list:
type: str
default: ""
description: OvS DPDK PMD Core list
edpm_ovs_dpdk_lcore_list:
type: str
default: ""
description: OvS DPDK LCore list
edpm_ovs_dpdk_memory_channels:
type: int
default: 4
description: OvS DPDK memory channels
edpm_ovs_dpdk_extra:
type: str
default: ""
description: OvS DPDK extra configs
edpm_ovs_dpdk_socket_memory:
type: str
default: ""
description: OvS DPDK Socket Memory
edpm_ovs_dpdk_revalidator_cores:
type: str
default: ""
description: DPDK revalidator core list
edpm_ovs_dpdk_handler_cores:
type: str
default: ""
description: OvS DPDK handler Core list
edpm_ovs_dpdk_emc_insertion_probablity:
type: str
default: ""
description: OvS DPDK EMAC insertion probablity
edpm_ovs_dpdk_enable_tso:
type: bool
default: false
description: OvS DPDK TSO enable or not
edpm_ovs_dpdk_pmd_auto_lb:
type: bool
default: false
description: OvS DPDK PMD auto load balance enable or not
edpm_ovs_dpdk_pmd_load_threshold:
type: str
default: ""
description: OvS DPDK PMD load threshold
edpm_ovs_dpdk_pmd_improvement_threshold:
type: str
default: ""
description: OvS DPDK PMD improvement threshold
edpm_ovs_dpdk_pmd_rebal_interval:
type: str
default: ""
description: OvS DPDK PMD rebalance interval
edpm_ovs_dpdk_vhost_postcopy_support:
type: bool
default: false
description: OvS DPDK vhost postcopy support enable or not
edpm_ovs_dpdk_vhost_postcopy_ovs_options:
type: str
default: ""
description: OvS DPDK vhost postcopy ovs options
43 changes: 43 additions & 0 deletions roles/edpm_ovs_dpdk/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# Copyright 2023 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


galaxy_info:
namespace: openstack
author: OpenStack
description: EDPM OpenStack Role -- edpm_ovs_dpdk
company: Red Hat
license: Apache-2.0
min_ansible_version: '2.9'
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: 'EL'
versions:
- '8'
- '9'

galaxy_tags:
- edpm


# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []
3 changes: 3 additions & 0 deletions roles/edpm_ovs_dpdk/molecule/default/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
collections:
- name: community.general
22 changes: 22 additions & 0 deletions roles/edpm_ovs_dpdk/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# Copyright 2023 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


- name: Converge
become: true
hosts: all
roles:
- role: "osp.edpm.edpm_ovs_dpdk"
30 changes: 30 additions & 0 deletions roles/edpm_ovs_dpdk/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
dependency:
name: galaxy
options:
role-file: collections.yml
driver:
name: podman
platforms:
- command: /sbin/init
dockerfile: ../../../../molecule/common/Containerfile.j2
image: ${EDPM_ANSIBLE_MOLECULE_IMAGE:-"ubi9/ubi-init"}
name: instance
privileged: true
registry:
url: ${EDPM_ANSIBLE_MOLECULE_REGISTRY:-"registry.access.redhat.com"}
ulimits:
- host
provisioner:
log: true
name: ansible
scenario:
test_sequence:
- dependency
- destroy
- create
- prepare
- converge
- destroy
verifier:
name: ansible
23 changes: 23 additions & 0 deletions roles/edpm_ovs_dpdk/molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


- name: Prepare test_deps
hosts: all
roles:
- role: ../../../../molecule/common/test_deps
test_deps_setup_edpm: true
test_deps_setup_stream: true
- role: env_data
Loading

0 comments on commit 8205f7f

Please sign in to comment.