Merge "Add port hardware offload extension"

This commit is contained in:
Zuul 2023-06-28 09:01:27 +00:00 committed by Gerrit Code Review
commit d5acebbe7b
17 changed files with 124 additions and 13 deletions

View File

@ -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': [<hardware_offload_type>]".
Show port details
=================

View File

@ -88,6 +88,7 @@
"b20bb47f-5d6d-45a6-8fe7-2c1b44f0db73"
]
},
"propagate_uplink_status": false
"propagate_uplink_status": false,
"hardware_offload_type": "switchdev"
}
}

View File

@ -76,6 +76,7 @@
"b20bb47f-5d6d-45a6-8fe7-2c1b44f0db73"
]
},
"propagate_uplink_status": false
"propagate_uplink_status": false,
"hardware_offload_type": ""
}
}

View File

@ -74,6 +74,7 @@
"b20bb47f-5d6d-45a6-8fe7-2c1b44f0db73"
]
},
"propagate_uplink_status": false
"propagate_uplink_status": false,
"hardware_offload_type": ""
}
}

View File

@ -13,6 +13,7 @@
"mac_address": "fa:14:2a:b3:cb:f0"
}
],
"propagate_uplink_status": false
"propagate_uplink_status": false,
"hardware_offload_type": ""
}
}

View File

@ -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": ""
}
}

View File

@ -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": ""
}
}

View File

@ -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": ""
}
}

View File

@ -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": ""
}
}

View File

@ -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": ""
}
]
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -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,

View File

@ -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 = []

View File

@ -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,
)

View File

@ -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,)

View File

@ -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': [<hardware_offload_type>]". 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.