diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py index 40702650..3ccdc9ff 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. # -# Copyright (c) 2013-2021 Wind River Systems, Inc. +# Copyright (c) 2013-2023 Wind River Systems, Inc. # from __future__ import absolute_import @@ -242,7 +242,7 @@ class Port(base.APIResourceWrapper): 'psvendor', 'psdevice', 'numa_node', 'mac', 'mtu', 'speed', 'link_mode', 'capabilities', 'host_uuid', 'interface_uuid', 'bootp', 'autoneg', 'type', 'sriov_numvfs', 'sriov_totalvfs', - 'sriov_vfs_pci_address', 'sriov_vf_driver', + 'sriov_vfs_pci_address', 'sriov_vf_driver', 'max_tx_rate', 'driver', 'dpdksupport', 'neighbours'] def __init__(self, apiresource): @@ -1961,7 +1961,7 @@ class Interface(base.APIResourceWrapper): 'aemode', 'txhashpolicy', 'primary_reselect', 'vlan_id', 'uses', 'used_by', 'ihost_uuid', 'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool', - 'sriov_numvfs', 'sriov_vf_driver'] + 'sriov_numvfs', 'sriov_vf_driver', 'max_tx_rate'] def __init__(self, apiresource): super(Interface, self).__init__(apiresource) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py index 1a8ff69d..a7fdca5b 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/forms.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2021 Wind River Systems, Inc. +# Copyright (c) 2013-2023 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -379,6 +379,23 @@ class AddInterface(forms.SelfHandlingForm): 'data-switch-on': 'ipv6_mode', 'data-ipv6_mode-pool': 'IPv6 Address Pool'})) + max_tx_rate = forms.IntegerField( + label=_("Max Tx Rate"), + initial=0, + min_value=0, + required=False, + help_text=_('Allowed maximum transmit bandwidth, in Mbps, for the ' + 'specified VF. Setting this parameter to 0 disables ' + 'rate limiting.'), + error_messages={'invalid': _('Max Tx Rate must be ' + 'equal or greater than 0.')}, + widget=forms.TextInput( + attrs={ + 'class': 'switched', + 'data-switch-on': 'interface_type', + 'data-slug': 'max_tx_rate', + 'data-interface_type-vf': 'Max Tx Rate'})) + failure_url = 'horizon:admin:inventory:detail' def __init__(self, *args, **kwargs): @@ -602,6 +619,13 @@ class AddInterface(forms.SelfHandlingForm): del data['sriov_numvfs'] del data['sriov_vf_driver'] + if data['iftype'] == 'vf': + if not data['max_tx_rate']: + data['max_tx_rate'] = 0 + data['max_tx_rate'] = str(data['max_tx_rate']) + else: + del data['max_tx_rate'] + del data['datanetworks'] del data['networks'] interface = sysinv.host_interface_create(request, **data) @@ -917,6 +941,13 @@ class UpdateInterface(AddInterface): if 'sriov_vf_driver' in data: data['sriov_vf_driver'] = str(data['sriov_vf_driver']) + if data['iftype'] == 'vf': + if not data['max_tx_rate']: + data['max_tx_rate'] = 0 + data['max_tx_rate'] = str(data['max_tx_rate']) + else: + del data['max_tx_rate'] + # Explicitly set iftype when user selects pci-pt or pci-sriov ifclass = \ flatten(list(nt) for nt in self.fields['ifclass'].choices) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/views.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/views.py index ab6835ca..6dd61afb 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/views.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/interfaces/views.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2021 Wind River Systems, Inc. +# Copyright (c) 2013-2023 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -229,6 +229,7 @@ class UpdateView(forms.ModalFormView): 'sriov_numvfs': interface.sriov_numvfs, 'sriov_vf_driver': interface.sriov_vf_driver, 'imtu': interface.imtu, + 'max_tx_rate': interface.max_tx_rate, 'ipv4_mode': getattr(interface, 'ipv4_mode', 'disabled'), 'ipv4_pool': getattr(interface, 'ipv4_pool', None), 'ipv6_mode': getattr(interface, 'ipv6_mode', 'disabled'), diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/templates/inventory/interfaces/_detail_overview.html b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/templates/inventory/interfaces/_detail_overview.html index 481960fc..ca6a03ac 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/templates/inventory/interfaces/_detail_overview.html +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/admin/inventory/templates/inventory/interfaces/_detail_overview.html @@ -36,5 +36,7 @@
{{ interface.sriov_numvfs|default:_("None") }}
{% trans "Virtual Function Driver" %}
{{ interface.sriov_vf_driver|default:_("None") }}
+
{% trans "Max Tx Rate" %}
+
{{ interface.max_tx_rate|default:_("None") }}