From 842a43b515c1879eb64c69848e1a3e9714d67385 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Tue, 21 Mar 2017 17:14:17 -0400 Subject: [PATCH] Add NIC namespace and features Adds a set of traits representing features that hardware networking interface controllers expose. A number of source documents were used to come up with these traits: https://review.openstack.org/#/c/341341/4/specs/newton/approved/standardize-network-capabilities.rst https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/network-nic-offloads.html https://www.kernel.org/doc/Documentation/networking/scaling.txt https://www.kernel.org/doc/Documentation/networking/multiqueue.txt Change-Id: If8a9f08b8b45ebcac53ea9a406c210605b163516 --- os_traits/__init__.py | 5 ++++ os_traits/hw/nic/__init__.py | 25 ++++++++++++++++++++ os_traits/hw/nic/accel.py | 26 +++++++++++++++++++++ os_traits/hw/nic/dcb.py | 24 +++++++++++++++++++ os_traits/hw/nic/offload.py | 38 +++++++++++++++++++++++++++++++ os_traits/hw/nic/sriov.py | 25 ++++++++++++++++++++ os_traits/tests/test_os_traits.py | 4 ++++ 7 files changed, 147 insertions(+) create mode 100644 os_traits/hw/nic/__init__.py create mode 100644 os_traits/hw/nic/accel.py create mode 100644 os_traits/hw/nic/dcb.py create mode 100644 os_traits/hw/nic/offload.py create mode 100644 os_traits/hw/nic/sriov.py diff --git a/os_traits/__init__.py b/os_traits/__init__.py index c246abb..d585e1c 100644 --- a/os_traits/__init__.py +++ b/os_traits/__init__.py @@ -25,6 +25,11 @@ CUSTOM_NAMESPACE = 'CUSTOM_' # Each submodule registers its symbols with the os_traits module namespace from os_traits.hw.cpu import x86 # noqa +from os_traits.hw import nic # noqa +from os_traits.hw.nic import accel # noqa +from os_traits.hw.nic import dcb # noqa +from os_traits.hw.nic import offload # noqa +from os_traits.hw.nic import sriov # noqa from os_traits.storage import disk # noqa diff --git a/os_traits/hw/nic/__init__.py b/os_traits/hw/nic/__init__.py new file mode 100644 index 0000000..ffc0f4d --- /dev/null +++ b/os_traits/hw/nic/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# 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 os_traits import utils + +register = utils.register_fn(__name__) + +# A few generalized capabilities of some NICs +register('SRIOV') # NIC supports partitioning via SR-IOV +register('MULTIQUEUE') # >1 receive and transmit queues +register('VMDQ') # Virtual machine device queues +# Some NICs allow processing pipelines to be programmed via FPGAs embedded in +# the NIC itself... +register('PROGRAMMABLE_PIPELINE') diff --git a/os_traits/hw/nic/accel.py b/os_traits/hw/nic/accel.py new file mode 100644 index 0000000..267580b --- /dev/null +++ b/os_traits/hw/nic/accel.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +# 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 os_traits import utils + +register = utils.register_fn(__name__) + +register('SSL') # SSL crypto +register('IPSEC') # IP-Sec crypto +register('TLS') # TLS crypto +register('DIFFIEH') # Diffie-Hellmann crypto +register('RSA') # RSA crypto +register('ECC') # Eliptic Curve crypto +register('LZS') # LZS compression +register('DEFLATE') # Deflate compression diff --git a/os_traits/hw/nic/dcb.py b/os_traits/hw/nic/dcb.py new file mode 100644 index 0000000..b0a643e --- /dev/null +++ b/os_traits/hw/nic/dcb.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +# 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 os_traits import utils + +register = utils.register_fn(__name__) + +# IEEE 802.1Qbb Priority-flow control +register('PFC') +# IEEE 802.1Qaz Enhanced Transmission Selection +register('ETS') +# IEEE 802.1Qau Quantized Congestion Notification +register('QCN') diff --git a/os_traits/hw/nic/offload.py b/os_traits/hw/nic/offload.py new file mode 100644 index 0000000..1ea2714 --- /dev/null +++ b/os_traits/hw/nic/offload.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +# 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 os_traits import utils + +register = utils.register_fn(__name__) + +register('TSO') # TCP segmentation +register('GRO') # Generic receive +register('GSO') # Generic segmentation +register('UFO') # UDP Fragmentation +register('LRO') # Large receive +register('LSO') # Large send +register('TCS') # TCP Checksum +register('UCS') # UDP Checksum +register('SCS') # SCTP Checksum +register('L2CRC') # Layer-2 CRC +register('FDF') # Intel Flow-Director Filter +register('RXVLAN') # VLAN receive tunnel segmentation +register('TXVLAN') # VLAN transmit tunnel segmentation +register('VXLAN') # VxLAN tunneling +register('GRE') # GRE tunneling +register('GENEVE') # Geneve tunneling +register('TXUDP') # UDP transmit tunnel segmentation +register('QINQ') # QinQ specification +register('RDMA') # remote direct memory access +register('RXHASH') # receive hashing diff --git a/os_traits/hw/nic/sriov.py b/os_traits/hw/nic/sriov.py new file mode 100644 index 0000000..72cfcb0 --- /dev/null +++ b/os_traits/hw/nic/sriov.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# 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 os_traits import utils + +register = utils.register_fn(__name__) + +# The function (virtual or physical) can restrict transmit rates +register('QOS_TX') +# The function (virtual or physical) can restrict receive rates +register('QOS_RX') +# The function (virtual or physical) can set up multiple receive and transmit +# queues for receive-side scaling +register('MULTIQUEUE') diff --git a/os_traits/tests/test_os_traits.py b/os_traits/tests/test_os_traits.py index d84a5b5..28c0cf9 100644 --- a/os_traits/tests/test_os_traits.py +++ b/os_traits/tests/test_os_traits.py @@ -14,6 +14,7 @@ import os_traits as ot from os_traits.hw.cpu import x86 +from os_traits.hw.nic import offload from os_traits.tests import base @@ -28,17 +29,20 @@ class TestSymbols(base.TestCase): # And the "leaf-module" namespace... self.assertEqual(x86.SSE42, ot.HW_CPU_X86_SSE42) + self.assertEqual(offload.TSO, ot.HW_NIC_OFFLOAD_TSO) def test_get_symbol_names(self): names = ot.get_symbol_names() self.assertIn("HW_CPU_X86_AVX2", names) self.assertIn("STORAGE_DISK_SSD", names) + self.assertIn("HW_NIC_SRIOV", names) def test_get_traits(self): traits = ot.get_traits('HW_CPU') self.assertIn("HW_CPU_X86_SSE42", traits) self.assertIn(ot.HW_CPU_X86_AVX2, traits) self.assertNotIn(ot.STORAGE_DISK_SSD, traits) + self.assertNotIn(ot.HW_NIC_SRIOV, traits) def test_check_traits(self): traits = set(["HW_CPU_X86_SSE42", "HW_CPU_X86_XOP"])