Skip to content

Commit

Permalink
Enable Hints.
Browse files Browse the repository at this point in the history
Signed-off-by: Amber <kumar.amber@intel.com>
  • Loading branch information
kamber-intel committed May 26, 2024
1 parent efbfd70 commit fd646d5
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 96 deletions.
9 changes: 0 additions & 9 deletions detd/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,3 @@ def __init__(self, template, params):
data = template.substitute(params).replace('\n', '')

super().__init__(data)


class Options:
"""Methods to assign parameters to passs into one convenient Object.
Used for: Passing parameters in Python script for manual customization of the qdisc. """
def __init__(self):

self.qdiscmap = "nomap"

45 changes: 27 additions & 18 deletions detd/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@

from ..logger import get_logger

from ..scheduler import TxCapability
from ..scheduler import DataPath

logger = get_logger(__name__)




def from_pci_id(pci_id):

# Retrieve all the subclasses inheriting from class Device
Expand All @@ -42,16 +41,6 @@ def from_pci_id(pci_id):

raise NameError("Unrecognized PCI ID: {}".format(pci_id))




class Capability(enum.Enum):
Qbv = 0
Qbu = 1
LTC = 2



class Device:

"""
Expand All @@ -71,7 +60,11 @@ def __init__(self, num_tx_queues, num_rx_queues):
self.systeminfo = SystemInformation()
self.systemconf = SystemConfigurator()

self.capabilities = []
self.tx_capabilities = TxCapability.default()
self.data_path_capabilities = DataPath.default()
self.launch_time_control = False
self.TxSelectionOffload = False
self.preemption = False

self.num_tx_queues = num_tx_queues
self.num_rx_queues = num_rx_queues
Expand All @@ -85,11 +78,11 @@ def __init__(self, num_tx_queues, num_rx_queues):
self.features = {}


def setup(self, interface, mapping, scheduler, stream):
def setup(self, interface, mapping, scheduler, stream, hints):
'''Performs the configuration of the talker stream provided.
'''

self.systemconf.setup(interface, mapping, scheduler, stream)
self.systemconf.setup(interface, mapping, scheduler, stream, hints)


def get_rate(self, interface):
Expand Down Expand Up @@ -127,5 +120,21 @@ def supports_schedule(self, schedule):
raise NotImplementedError("The handler class for the device must implement this function")


def supports_qbv(self):
return Capability.Qbv in self.capabilities
def get_tx_capabilities(self):
return self.tx_capabilities

def supports_ltc(self):
"""Returns True if the device supports Launch Time Control (LTC),
False otherwise."""
return self.launch_time_control

def supports_tx_selection_offload(self):
return self.TxSelectionOffload

def get_data_path(self):
'''Returns True if the device supports the specified DataPath capability,
False otherwise.'''
return self.data_path_capabilities

def supports_preemption(self):
return self.preemption
11 changes: 7 additions & 4 deletions detd/devices/intel_i210.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

from ..logger import get_logger

from .device import Capability
from ..scheduler import TxCapability
from .device import Device

from ..scheduler import DataPath

logger = get_logger(__name__)

Expand All @@ -27,8 +28,6 @@ class IntelI210(Device):

NUM_TX_QUEUES = 4
NUM_RX_QUEUES = 4

CAPABILITIES = [Capability.LTC]

PCI_IDS_VALID = ['8086:1533', '8086:1536', '8086:1537', '8086:1538', '8086:157B',
'8086:157C', '8086:15F6']
Expand All @@ -44,7 +43,11 @@ def __init__(self, pci_id):

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

self.capabilities = [Capability.LTC]
self.launch_time_control = True
self.data_path_capabilities = DataPath.AF_PACKET
self.tx_capabilities = TxCapability.Qbv
self.TxSelectionOffload = False
self.preemption = False

self.features['rxvlan'] = 'off'

Expand Down
11 changes: 7 additions & 4 deletions detd/devices/intel_i225.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

from ..logger import get_logger

from .device import Capability
from ..scheduler import TxCapability
from .device import Device

from ..scheduler import DataPath

logger = get_logger(__name__)

Expand All @@ -26,8 +27,6 @@ class IntelI225(Device):
NUM_TX_QUEUES = 4
NUM_RX_QUEUES = 4

CAPABILITIES = [Capability.Qbv]

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

Expand All @@ -52,7 +51,11 @@ def __init__(self, pci_id):
if pci_id in IntelI225.PCI_IDS_UNPROGRAMMED:
raise "The flash image in this i225 device is empty, or the NVM configuration loading failed."

self.capabilities = [Capability.Qbv]
self.launch_time_control = False
self.data_path_capabilities = DataPath.AF_PACKET
self.tx_capabilities = TxCapability.Qbv
self.TxSelectionOffload = True
self.preemption = False

self.features['rxvlan'] = 'off'
#self.features['hw-tc-offload'] = 'on'
Expand Down
9 changes: 7 additions & 2 deletions detd/devices/intel_mgbeehl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

from ..logger import get_logger

from .device import Capability
from ..scheduler import TxCapability
from .device import Device

from ..scheduler import DataPath

logger = get_logger(__name__)

Expand Down Expand Up @@ -57,7 +58,11 @@ def __init__(self, pci_id):

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

self.capabilities = [Capability.Qbv]
self.launch_time_control = True
self.data_path_capabilities = DataPath.AF_PACKET
self.tx_capabilities = TxCapability.Qbv
self.TxSelectionOffload = False
self.preemption = False

self.features['rxvlan'] = 'off'
self.features['hw-tc-offload'] = 'on'
Expand Down
6 changes: 5 additions & 1 deletion detd/ipc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ message StreamQosRequest {
uint32 txmax = 8;
bool setup_socket = 9;
uint32 basetime = 10;
string qdiscmap = 11;
uint32 tx_selection = 11;
bool tx_selection_offload = 12;
uint32 data_path = 13;
bool preemption = 14;
bool launch_time_control = 15;
}


Expand Down
73 changes: 60 additions & 13 deletions detd/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
from .scheduler import Scheduler
from .scheduler import Traffic
from .scheduler import TrafficType
from .scheduler import Hints
from .scheduler import TxCapability
from .scheduler import DataPath

from .systemconf import SystemInformation
from .mapping import Mapping
from .mapping import MappingFixed
from .mapping import MappingFlexible
from .common import Check

from .devices import device
Expand Down Expand Up @@ -62,8 +67,8 @@ def rate(self):
return self.device.get_rate(self)


def setup(self, mapping, scheduler, stream):
self.device.setup(self, mapping, scheduler, stream)
def setup(self, mapping, scheduler, stream, hints):
self.device.setup(self, mapping, scheduler, stream, hints)



Expand All @@ -86,7 +91,7 @@ def add_talker(self, config):
with self.lock:

if not config.interface.name in self.talker_manager:
interface_manager = InterfaceManager(config.interface, config.options)
interface_manager = InterfaceManager(config)
self.talker_manager[config.interface.name] = interface_manager

return self.talker_manager[config.interface.name].add_talker(config)
Expand All @@ -96,20 +101,20 @@ def add_talker(self, config):

class InterfaceManager():

def __init__(self, interface, options):
def __init__(self, config):

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

self.interface = interface
self.options = options
if self.options.qdiscmap == "nomap":
self.mapping = Mapping(self.interface)
self.interface = config.interface
self.hints = self._get_device_hints(config)

if self.hints.tx_selection == TxCapability.Qbv:
self.mapping = MappingFixed(self.interface)
else:
self.mapping = Mapping(self.interface, self.options)
self.mapping = MappingFlexible(self.interface)

self.scheduler = Scheduler(self.mapping)


def add_talker(self, config):
'''
Performs the local configuration for the configuration provided
Expand Down Expand Up @@ -174,7 +179,7 @@ def add_talker(self, config):

# Configure the system
try:
self.interface.setup(self.mapping, self.scheduler, config.stream)
self.interface.setup(self.mapping, self.scheduler, config.stream, self.hints)
except:
# Leave the internal structures in a consistent state
logger.error("Error applying the configuration on the system")
Expand Down Expand Up @@ -213,3 +218,45 @@ def update_base_time(self, config):
safety_margin = multiple * period

config.stream.base_time = (now + ns_until_next_cycle) + safety_margin

def _get_device_hints(self, config):

# Default config based on the device capabilies
tx_selection = config.interface.device.get_tx_capabilities()
tx_selection_offload = config.interface.device.supports_tx_selection_offload()
data_path = config.interface.device.get_data_path()
preemption = config.interface.device.supports_preemption()
launch_time_control = config.interface.device.supports_ltc()

# Check if the device supports the requested features
if config.hints.data_path is not None and DataPath(config.hints.data_path) != self.interface.device.get_data_path():
raise ValueError(f"Device does not support the requested DataPath feature."
f"Requested: {DataPath(config.hints.data_path)}, Device Capabilities: {self.interface.device.get_data_path()}")
else:
data_path = DataPath(config.hints.data_path)

if config.hints.tx_selection is not None and TxCapability(config.hints.tx_selection) != self.interface.device.get_tx_capabilities():
raise ValueError(f"Device does not support the requested Tx selection feature."
f"Requested: {TxCapability(config.hints.tx_selection)}, Device Capabilities: {self.interface.device.get_tx_capabilities()}")
else:
tx_selection = TxCapability(config.hints.tx_selection)

if config.hints.launch_time_control is not None and config.hints.launch_time_control != self.interface.device.supports_ltc():
raise ValueError(f"Device does not support the requested launch_time_control feature."
f"Requested: {config.hints.launch_time_control}, Device Capabilities: {self.interface.device.supports_ltc()}")
else:
launch_time_control = config.hints.launch_time_control

if config.hints.tx_selection_offload is not None and config.hints.tx_selection_offload != self.interface.device.supports_tx_selection_offload():
raise ValueError(f"Device does not support the requested tx_selection_offload feature."
f"Requested: {config.hints.tx_selection_offload}, Device Capabilities: {self.interface.device.supports_tx_selection_offload()}")
else:
tx_selection_offload = config.hints.tx_selection_offload

if config.hints.preemption is not None and config.hints.preemption != self.interface.device.supports_preemption():
raise ValueError(f"Device does not support the requested preemption feature."
f"Requested: {config.hints.preemption}, Device Capabilities: {self.interface.device.supports_preemption()}")
else:
preemption = config.hints.preemption

return Hints(tx_selection, tx_selection_offload, data_path, preemption, launch_time_control)
16 changes: 5 additions & 11 deletions detd/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@





class MappingNaive():
class MappingFlexible():

"""
A class mapping the hardware and system resources (socket priorities,
Expand Down Expand Up @@ -209,7 +207,7 @@ def unmap_and_free_queue(self, tc):



class Mapping():
class MappingFixed():

"""
A class mapping the hardware and system resources (socket priorities,
Expand Down Expand Up @@ -245,15 +243,13 @@ class Mapping():
"""


def __init__(self, interface, options = None):
def __init__(self, interface):

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

# FIXME: make the number of Tx queues a parameter, so things are not hardcoded

self.interface = interface
self.options = options


# Socket priorities

Expand Down Expand Up @@ -357,10 +353,8 @@ def soprio_to_tc(self):
for tc, soprio in enumerate(self.tc_to_soprio):
mapping[soprio] = tc

if self.options is None:
return mapping
else:
return [int(x) for x in self.options.qdiscmap.split()]

return mapping


def assign_and_map(self, pcp, traffics):
Expand Down
6 changes: 5 additions & 1 deletion detd/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def send_qos_request(self, configuration, setup_socket):
request.txmin = configuration.stream.txoffset
request.txmax = configuration.stream.txoffset
request.setup_socket = setup_socket
request.qdiscmap = configuration.options.qdiscmap
request.tx_selection = configuration.hints.tx_selection.value
request.tx_selection_offload = configuration.hints.tx_selection_offload
request.data_path = configuration.hints.data_path.value
request.preemption = configuration.hints.preemption
request.launch_time_control = configuration.hints.launch_time_control

message = request.SerializeToString()
self.send(message)
Expand Down
Loading

0 comments on commit fd646d5

Please sign in to comment.