diff --git a/api-ref/source/v2/ports.inc b/api-ref/source/v2/ports.inc index 45509f4d0..aaf9be4de 100644 --- a/api-ref/source/v2/ports.inc +++ b/api-ref/source/v2/ports.inc @@ -220,6 +220,14 @@ attribute to port. If this attribute is set to ``false``, uplink status propagation is disabled. If this attribute is not specified, it is default to ``true`` which indicates uplink status propagation is enabled. +Hardware offload extension +========================== + +The ``port-hardware-offload`` extension adds ``hardware_offload_type`` +attribute to the port resource. This attribute stores the type of hardware +offload the port is going to use and will be populated in the port binding +profile information with "'capabilities': []". + Show port details ================= diff --git a/api-ref/source/v2/samples/ports/port-bind-create-response.json b/api-ref/source/v2/samples/ports/port-bind-create-response.json index 9f7a0613d..be50990b8 100644 --- a/api-ref/source/v2/samples/ports/port-bind-create-response.json +++ b/api-ref/source/v2/samples/ports/port-bind-create-response.json @@ -88,6 +88,7 @@ "b20bb47f-5d6d-45a6-8fe7-2c1b44f0db73" ] }, - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "switchdev" } } diff --git a/api-ref/source/v2/samples/ports/port-bind-show-response.json b/api-ref/source/v2/samples/ports/port-bind-show-response.json index ba5d8e262..82cc1050c 100644 --- a/api-ref/source/v2/samples/ports/port-bind-show-response.json +++ b/api-ref/source/v2/samples/ports/port-bind-show-response.json @@ -76,6 +76,7 @@ "b20bb47f-5d6d-45a6-8fe7-2c1b44f0db73" ] }, - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } } diff --git a/api-ref/source/v2/samples/ports/port-bind-update-response.json b/api-ref/source/v2/samples/ports/port-bind-update-response.json index 95744b3e2..193c5c73f 100644 --- a/api-ref/source/v2/samples/ports/port-bind-update-response.json +++ b/api-ref/source/v2/samples/ports/port-bind-update-response.json @@ -74,6 +74,7 @@ "b20bb47f-5d6d-45a6-8fe7-2c1b44f0db73" ] }, - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } } diff --git a/api-ref/source/v2/samples/ports/port-create-request.json b/api-ref/source/v2/samples/ports/port-create-request.json index 7cc98de70..edfcc2fc2 100644 --- a/api-ref/source/v2/samples/ports/port-create-request.json +++ b/api-ref/source/v2/samples/ports/port-create-request.json @@ -13,6 +13,7 @@ "mac_address": "fa:14:2a:b3:cb:f0" } ], - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } } diff --git a/api-ref/source/v2/samples/ports/port-create-response.json b/api-ref/source/v2/samples/ports/port-create-response.json index df9f5e4ef..acbb54e6c 100644 --- a/api-ref/source/v2/samples/ports/port-create-response.json +++ b/api-ref/source/v2/samples/ports/port-create-response.json @@ -51,6 +51,7 @@ "updated_at": "2016-03-08T20:19:41", "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } } diff --git a/api-ref/source/v2/samples/ports/port-remove-allowed-address-pairs-response.json b/api-ref/source/v2/samples/ports/port-remove-allowed-address-pairs-response.json index 9023184de..0cc9c19ed 100644 --- a/api-ref/source/v2/samples/ports/port-remove-allowed-address-pairs-response.json +++ b/api-ref/source/v2/samples/ports/port-remove-allowed-address-pairs-response.json @@ -41,6 +41,7 @@ "qos_network_policy_id": null, "qos_policy_id": null, "resource_request": null, - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } } diff --git a/api-ref/source/v2/samples/ports/port-show-response.json b/api-ref/source/v2/samples/ports/port-show-response.json index 97089780f..3e3d4bba5 100644 --- a/api-ref/source/v2/samples/ports/port-show-response.json +++ b/api-ref/source/v2/samples/ports/port-show-response.json @@ -44,6 +44,7 @@ "updated_at": "2016-03-08T20:19:41", "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } } diff --git a/api-ref/source/v2/samples/ports/port-update-response.json b/api-ref/source/v2/samples/ports/port-update-response.json index e594e9769..f89e959ce 100644 --- a/api-ref/source/v2/samples/ports/port-update-response.json +++ b/api-ref/source/v2/samples/ports/port-update-response.json @@ -51,6 +51,7 @@ "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "port_security_enabled": false, - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } } diff --git a/api-ref/source/v2/samples/ports/ports-bind-list-response.json b/api-ref/source/v2/samples/ports/ports-bind-list-response.json index d671867f3..9946d12d3 100644 --- a/api-ref/source/v2/samples/ports/ports-bind-list-response.json +++ b/api-ref/source/v2/samples/ports/ports-bind-list-response.json @@ -70,7 +70,8 @@ }, "tags": ["tag1,tag2"], "tenant_id": "", - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" }, { "admin_state_up": true, @@ -119,7 +120,8 @@ "qos_policy_id": null, "tags": ["tag1,tag2"], "tenant_id": "d397de8a63f341818f198abb0966f6f3", - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" } ] } diff --git a/api-ref/source/v2/samples/ports/ports-bulk-create-request.json b/api-ref/source/v2/samples/ports/ports-bulk-create-request.json index 94b5e5254..222d714af 100644 --- a/api-ref/source/v2/samples/ports/ports-bulk-create-request.json +++ b/api-ref/source/v2/samples/ports/ports-bulk-create-request.json @@ -9,7 +9,8 @@ { "admin_state_up": false, "name": "sample_port_2", - "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7" + "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7", + "hardware_offload_type": "switchdev" } ] } diff --git a/api-ref/source/v2/samples/ports/ports-bulk-create-response.json b/api-ref/source/v2/samples/ports/ports-bulk-create-response.json index efa8b9b1f..b16f121c6 100644 --- a/api-ref/source/v2/samples/ports/ports-bulk-create-response.json +++ b/api-ref/source/v2/samples/ports/ports-bulk-create-response.json @@ -40,7 +40,8 @@ "qos_network_policy_id": null, "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "port_security_enabled": false, - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "" }, { "admin_state_up": false, @@ -83,7 +84,8 @@ "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": null, "port_security_enabled": false, - "propagate_uplink_status": false + "propagate_uplink_status": false, + "hardware_offload_type": "switchdev" } ] } diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index bc6d469c4..33dcdfe2e 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -90,6 +90,7 @@ from neutron_lib.api.definitions import network_segment_range from neutron_lib.api.definitions import pagination from neutron_lib.api.definitions import port from neutron_lib.api.definitions import port_device_profile +from neutron_lib.api.definitions import port_hardware_offload_type from neutron_lib.api.definitions import port_hint_ovs_tx_steering from neutron_lib.api.definitions import port_hints from neutron_lib.api.definitions import port_mac_address_override @@ -243,6 +244,7 @@ _ALL_API_DEFINITIONS = { pagination, port, port_device_profile, + port_hardware_offload_type, port_hints, port_hint_ovs_tx_steering, port_mac_address_override, diff --git a/neutron_lib/api/definitions/port_hardware_offload_type.py b/neutron_lib/api/definitions/port_hardware_offload_type.py new file mode 100644 index 000000000..349c919db --- /dev/null +++ b/neutron_lib/api/definitions/port_hardware_offload_type.py @@ -0,0 +1,50 @@ +# Copyright (c) 2023 Red Hat, Inc. +# +# 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. + +from neutron_lib.api import converters +from neutron_lib.api.definitions import port +from neutron_lib import constants + + +ALIAS = 'port-hardware-offload-type' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Port hardware offload' +DESCRIPTION = "Expose port hardware offload extension" +UPDATED_TIMESTAMP = "2023-05-09T10:00:00-00:00" +RESOURCE_NAME = port.RESOURCE_NAME +COLLECTION_NAME = port.COLLECTION_NAME +HARDWARE_OFFLOAD_TYPE = 'hardware_offload_type' + +RESOURCE_ATTRIBUTE_MAP = { + COLLECTION_NAME: { + HARDWARE_OFFLOAD_TYPE: { + 'allow_post': True, + 'allow_put': False, + 'convert_to': converters.convert_to_string, + 'enforce_policy': True, + 'required_by_policy': False, + 'default': None, + 'is_visible': True, + 'validate': { + 'type:values': constants.VALID_HWOL_TYPES} + } + }, +} + +SUB_RESOURCE_ATTRIBUTE_MAP = None +ACTION_MAP = {} +ACTION_STATUS = {} +REQUIRED_EXTENSIONS = [] +OPTIONAL_EXTENSIONS = [] diff --git a/neutron_lib/constants.py b/neutron_lib/constants.py index 1dce75a0d..e08d8ef97 100644 --- a/neutron_lib/constants.py +++ b/neutron_lib/constants.py @@ -691,3 +691,8 @@ MAX_ASNUM = 65535 MAX_4BYTE_ASNUM = 4294967295 SUPPORTED_AUTH_TYPES = ['none', 'md5'] + +# Hardware offload types. +HWOL_TYPE_SWITCHDEV = 'switchdev' +VALID_HWOL_TYPES = (HWOL_TYPE_SWITCHDEV, + ) diff --git a/neutron_lib/tests/unit/api/definitions/test_port_hardware_offload.py b/neutron_lib/tests/unit/api/definitions/test_port_hardware_offload.py new file mode 100644 index 000000000..df0a5916e --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_port_hardware_offload.py @@ -0,0 +1,22 @@ +# Copyright 2023 Red Hat, Inc. +# +# 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. + +from neutron_lib.api.definitions import port_hardware_offload_type +from neutron_lib.tests.unit.api.definitions import base + + +class PortHardwareOffloadTypeDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = port_hardware_offload_type + extension_resources = (port_hardware_offload_type.COLLECTION_NAME,) + extension_attributes = (port_hardware_offload_type.HARDWARE_OFFLOAD_TYPE,) diff --git a/releasenotes/notes/port-hardware-offload-388906d9448426ad.yaml b/releasenotes/notes/port-hardware-offload-388906d9448426ad.yaml new file mode 100644 index 000000000..34d95d280 --- /dev/null +++ b/releasenotes/notes/port-hardware-offload-388906d9448426ad.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + The ``port-hardware-offload`` extension adds ``hardware_offload_type`` + attribute to the port resource. This new attribute stores the type + of hardware offload the port is going to use and will be populated + in the port binding profile information with + "'capabilities': []". This extension is still + not read by Nova; this is the reason Neutron still populates the port + binding profile. The value of this parameter will not be updated if + the port binding profile information is updated.