Skip to content

Commit

Permalink
Calculating Txoffset-hardware delays
Browse files Browse the repository at this point in the history
+
Editing tests to encompass new variables being returned + testing the values of it

hardware latency for i225 and rename for i210

small fix
  • Loading branch information
jeppex1 committed Mar 27, 2023
1 parent c208712 commit fbe47a5
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 21 deletions.
7 changes: 6 additions & 1 deletion detd/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ class Device:
"""

def __init__(self, num_tx_queues, num_rx_queues):
def __init__(self, num_tx_queues, num_rx_queues, hardware_delay_min, hardware_delay_max):
"""
num_tx_queues: number of Tx queues
num_rx_queues: number of Rx queues
hardware_delay_min: minimum delay caused by hardware
hardware_delay_max: maximum delay caused by hardware
"""

self.systeminfo = SystemInformation()
Expand All @@ -77,6 +79,9 @@ def __init__(self, num_tx_queues, num_rx_queues):
self.num_rx_queues = num_rx_queues
self.best_effort_tx_queues = list(range(0, num_tx_queues))


self.hardware_delay_min = hardware_delay_min
self.hardware_delay_max = hardware_delay_max
# self.features
# Taking the name from ethtool's "features" option.
# Currently, the code just passes the key and value to ethtool.
Expand Down
6 changes: 5 additions & 1 deletion detd/devices/intel_i210.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class IntelI210(Device):

CAPABILITIES = [Capability.LTC]

#MAC+PHY latency assuming 100 mbit link
HARDWARE_LATENCY_MIN = 2168
HARDWARE_LATENCY_MAX = 2384

PCI_IDS_VALID = ['8086:1533', '8086:1536', '8086:1537', '8086:1538', '8086:157B',
'8086:157C', '8086:15F6']

Expand All @@ -42,7 +46,7 @@ def __init__(self, pci_id):

logger.info(f"Initializing {__class__.__name__}")

super().__init__(IntelI210.NUM_TX_QUEUES, IntelI210.NUM_RX_QUEUES)
super().__init__(IntelI210.NUM_TX_QUEUES, IntelI210.NUM_RX_QUEUES, IntelI210.HARDWARE_LATENCY_MIN, IntelI210.HARDWARE_LATENCY_MAX)

self.capabilities = [Capability.LTC]

Expand Down
6 changes: 5 additions & 1 deletion detd/devices/intel_i225.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class IntelI225(Device):

CAPABILITIES = [Capability.Qbv]

#Placeholder MAC+PHY latency
HARDWARE_LATENCY_MIN = 1000
HARDWARE_LATENCY_MAX = 2000

# Devices supporting TSN: i225-LM, i225-IT
PCI_IDS_VALID = ['8086:0D9F', '8086:15F2']

Expand All @@ -44,7 +48,7 @@ def __init__(self, pci_id):

logger.info(f"Initializing {__class__.__name__}")

super().__init__(IntelI225.NUM_TX_QUEUES, IntelI225.NUM_RX_QUEUES)
super().__init__(IntelI225.NUM_TX_QUEUES, IntelI225.NUM_RX_QUEUES, IntelI225.HARDWARE_LATENCY_MIN, IntelI225.HARDWARE_LATENCY_MAX)

if pci_id in IntelI225.PCI_IDS_NON_TSN:
raise "This i225 device does not support TSN."
Expand Down
5 changes: 4 additions & 1 deletion detd/devices/intel_mgbeehl.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class IntelMgbeEhl(Device):
NUM_TX_QUEUES = 8
NUM_RX_QUEUES = 8

HARDWARE_DELAY_MIN = 1000
HARDWARE_DELAY_MAX = 2000

# PCI IDs associated to the host. This is Intel Elkhart Lake specific.
PCI_IDS_HOST = [ '8086:4B30', '8086:4B31', '8086:4B32']

Expand All @@ -55,7 +58,7 @@ def __init__(self, pci_id):

logger.info(f"Initializing {__class__.__name__}")

super().__init__(IntelMgbeEhl.NUM_TX_QUEUES, IntelMgbeEhl.NUM_RX_QUEUES)
super().__init__(IntelMgbeEhl.NUM_TX_QUEUES, IntelMgbeEhl.NUM_RX_QUEUES, IntelMgbeEhl.HARDWARE_DELAY_MIN, IntelMgbeEhl.HARDWARE_DELAY_MAX)

self.capabilities = [Capability.Qbv]

Expand Down
2 changes: 2 additions & 0 deletions detd/ipc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ message StreamQosResponse {
bool ok = 1;
string vlan_interface = 2;
uint32 socket_priority = 3;
int32 txminmac = 4;
int32 txmaxmac = 5;
}
6 changes: 5 additions & 1 deletion detd/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,15 @@ def add_talker(self, config):
self.mapping.unmap_and_free(soprio, traffic.tc, queue)
raise RuntimeError("Error applying the configuration on the system")

#Calculate MAC offset
txoffsetmin = config.stream.txoffset - self.interface.device.hardware_delay_max
txoffsetmax = config.stream.txoffset - self.interface.device.hardware_delay_min

# FIXME: generate the name to use for the VLAN interface in the manager
# instead of in the command string class.

vlan_interface = "{}.{}".format(self.interface.name, config.stream.vid)
return vlan_interface, soprio
return vlan_interface, soprio, txoffsetmin, txoffsetmax


# Unfortunately, not all devices accept base_time in the future, or base_time
Expand Down
4 changes: 3 additions & 1 deletion detd/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,7 @@ def add_talker(self, configuration):

vlan_interface = response.vlan_interface
soprio = response.socket_priority
txoffsetmin = response.txminmac
txoffsetmax = response.txmaxmac

return vlan_interface, soprio
return vlan_interface, soprio, txoffsetmin, txoffsetmax
22 changes: 13 additions & 9 deletions detd/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def receive_qos_request(self):
return request


def build_qos_response(self, ok, vlan_interface=None, soprio=None, fd=None):
def build_qos_response(self, ok, vlan_interface=None, soprio=None, txoffsetmin=None, txoffsetmax=None, fd=None):
response = StreamQosResponse()

response.ok = ok
Expand All @@ -209,15 +209,17 @@ def build_qos_response(self, ok, vlan_interface=None, soprio=None, fd=None):
if fd is None:
response.vlan_interface = vlan_interface
response.socket_priority = soprio
response.txminmac = txoffsetmin
response.txmaxmac = txoffsetmax

message = response.SerializePartialToString()
return message



def send_qos_response(self, ok, vlan_interface, soprio):
def send_qos_response(self, ok, vlan_interface, soprio, txoffsetmin, txoffsetmax):

message = self.build_qos_response(ok, vlan_interface, soprio)
message = self.build_qos_response(ok, vlan_interface, soprio, txoffsetmin, txoffsetmax)
self.send(message)


Expand Down Expand Up @@ -245,9 +247,9 @@ def _add_talker(self, request):

config = Configuration(interface, stream, traffic, options)

vlan_interface, soprio = self.server.manager.add_talker(config)
vlan_interface, soprio, txoffsetmin, txoffsetmax = self.server.manager.add_talker(config)

return vlan_interface, soprio
return vlan_interface, soprio, txoffsetmin, txoffsetmax


def _mock_add_talker(self, request):
Expand All @@ -273,9 +275,9 @@ def _mock_add_talker(self, request):

config = Configuration(interface, stream, traffic)

vlan_interface, soprio = self.server.manager.add_talker(config)
vlan_interface, soprio, txoffsetmin, txoffsetmax = self.server.manager.add_talker(config)

return vlan_interface, soprio
return vlan_interface, soprio, txoffsetmin, txoffsetmax


def _add_talker_socket(self, request):
Expand Down Expand Up @@ -325,16 +327,18 @@ def handle(self):
elif request.setup_socket == False:
try:
ok = False
vlan_interface, soprio = self.add_talker(request)
vlan_interface, soprio, txoffsetmin, txoffsetmax = self.add_talker(request)
ok = True
except Exception as ex:
logger.exception("Exception raised while setting up a talker")

if not ok:
vlan_interface = None
soprio = None
txoffsetmin = None
txoffsetmax = None

try:
self.send_qos_response(ok, vlan_interface, soprio)
self.send_qos_response(ok, vlan_interface, soprio, txoffsetmin, txoffsetmax)
except Exception as ex:
logger.exception("Exception raised while sending the QoS response after setting up a talker")
25 changes: 20 additions & 5 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ def test_add_talker_success(self):

with RunContext(self.mode):
manager = Manager()
vlan_interface, soprio = manager.add_talker(config)
vlan_interface, soprio, txoffsetmin, txoffsetmax = manager.add_talker(config)

self.assertEqual(vlan_interface, "eth0.3")
self.assertEqual(soprio, 7)

self.assertEqual(txoffsetmin, config.stream.txoffset-config.interface.device.hardware_delay_max)
self.assertEqual(txoffsetmax, config.stream.txoffset-config.interface.device.hardware_delay_min)


def test_add_max_talkers_success_and_error(self):

Expand Down Expand Up @@ -91,11 +94,14 @@ def test_add_max_talkers_success_and_error(self):
config = setup_config(self.mode)

with RunContext(self.mode):
vlan_interface, soprio = manager.add_talker(config)
vlan_interface, soprio, txoffsetmin, txoffsetmax = manager.add_talker(config)

self.assertEqual(vlan_interface, "eth0.3")
self.assertEqual(soprio, 7)

self.assertEqual(txoffsetmin, config.stream.txoffset-config.interface.device.hardware_delay_max)
self.assertEqual(txoffsetmax, config.stream.txoffset-config.interface.device.hardware_delay_min)

available_socket_prios = [8, 9, 10, 11, 12, 13]
available_tcs = [2, 3, 4, 5, 6, 7]
available_tx_queues = [2, 3, 4, 5, 6, 7]
Expand All @@ -108,11 +114,14 @@ def test_add_max_talkers_success_and_error(self):
config = setup_config(self.mode, interval=20*1000*1000, txoffset=600*1000)

with RunContext(self.mode):
vlan_interface, soprio = manager.add_talker(config)
vlan_interface, soprio, txoffsetmin, txoffsetmax = manager.add_talker(config)

self.assertEqual(vlan_interface, "eth0.3")
self.assertEqual(soprio, 8)

self.assertEqual(txoffsetmin, config.stream.txoffset-config.interface.device.hardware_delay_max)
self.assertEqual(txoffsetmax, config.stream.txoffset-config.interface.device.hardware_delay_min)

available_socket_prios = [9, 10, 11, 12, 13]
available_tcs = [3, 4, 5, 6, 7]
available_tx_queues = [3, 4, 5, 6, 7]
Expand All @@ -124,11 +133,14 @@ def test_add_max_talkers_success_and_error(self):
for txoffset_us in [800, 1000, 1400, 1800, 2200]:
config = setup_config(self.mode, interval=20*1000*1000, txoffset=txoffset_us*1000)
with RunContext(self.mode):
vlan_interface, soprio = manager.add_talker(config)
vlan_interface, soprio, txoffsetmin, txoffsetmax = manager.add_talker(config)

self.assertEqual(vlan_interface, "eth0.3")
self.assertEqual(soprio, 13)

self.assertEqual(txoffsetmin, config.stream.txoffset-config.interface.device.hardware_delay_max)
self.assertEqual(txoffsetmax, config.stream.txoffset-config.interface.device.hardware_delay_min)

available_socket_prios = []
available_tcs = []
available_tx_queues = []
Expand Down Expand Up @@ -176,11 +188,14 @@ def test_remove_max_talkers_success_and_error(self):
for txoffset_us in [200, 400, 800, 1000, 1400, 1800, 2200]:
config = setup_config(self.mode, interval=20*1000*1000, txoffset=txoffset_us*1000)
with RunContext(self.mode):
vlan_interface, soprio = manager.add_talker(config)
vlan_interface, soprio, txoffsetmin, txoffsetmax = manager.add_talker(config)

self.assertEqual(vlan_interface, "eth0.3")
self.assertEqual(soprio, 13)

self.assertEqual(txoffsetmin, config.stream.txoffset-config.interface.device.hardware_delay_max)
self.assertEqual(txoffsetmax, config.stream.txoffset-config.interface.device.hardware_delay_min)

available_socket_prios = []
available_tcs = []
available_tx_queues = []
Expand Down
4 changes: 3 additions & 1 deletion tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ def test_service_add_talker(self):

configuration = setup_configuration(self.mode)

vlan_interface, soprio = self.proxy.add_talker(configuration)
vlan_interface, soprio, txoffsetmin, txoffsetmax = self.proxy.add_talker(configuration)

self.assertEqual(vlan_interface, "eth1.3")
self.assertEqual(soprio, 7)
self.assertEqual(txoffsetmin, configuration.stream.txoffset-configuration.interface.device.hardware_delay_max)
self.assertEqual(txoffsetmax, configuration.stream.txoffset-configuration.interface.device.hardware_delay_min)



Expand Down

0 comments on commit fbe47a5

Please sign in to comment.