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 Jun 5, 2024
1 parent efbfd70 commit 9445d35
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 95 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,18 @@ def setup_stream_config():
vid = 3
pcp = 6

options = Options()
options.qdiscmap = "0 1 0 0 0 0 0 0 2 3 0 0 0 0 0 0"
preemption = False
launch_time_control = False
tx_selection_offload = False
datapath = DataPath.AF_PACKET
tx_selection = TxSelection.Qbv

interface = Interface(interface_name)
stream = StreamConfiguration(addr, vid, pcp, txoffset)
traffic = TrafficSpecification(interval, size)
hints = Hints(tx_selection, tx_selection_offload, datapath, preemption, launch_time_control)

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

return config

Expand Down
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"

40 changes: 26 additions & 14 deletions detd/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
from ..systemconf import SystemConfigurator
from ..systemconf import SystemInformation

from ..scheduler import DataPath
from ..scheduler import TxSelection
from ..scheduler import Hints

from ..logger import get_logger


logger = get_logger(__name__)




def from_pci_id(pci_id):

# Retrieve all the subclasses inheriting from class Device
Expand All @@ -42,16 +43,11 @@ 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 Down Expand Up @@ -85,11 +81,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 @@ -125,7 +121,23 @@ 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 default_hints(self):
'''Returns device supported default Hints.
'''
preemption = False
launch_time_control = False
tx_selection_offload = False
datapath = DataPath.AF_PACKET
tx_selection = TxSelection.Qbv

if Capability.Qbv in self.capabilities:
tx_selection_offload = True

return Hints(tx_selection, tx_selection_offload ,datapath, preemption, launch_time_control)

def check_hints(self, config):

if (config.hints is not None):
return True
return False
25 changes: 22 additions & 3 deletions detd/devices/intel_i210.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@

from ..logger import get_logger


from .device import Capability
from .device import Device

from ..scheduler import DataPath
from ..scheduler import TxSelection
from ..scheduler import Hints

logger = get_logger(__name__)

Expand All @@ -27,7 +31,7 @@ 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',
Expand All @@ -44,10 +48,10 @@ def __init__(self, pci_id):

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

self.capabilities = [Capability.LTC]

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

self.capabilities = [Capability.LTC]

# self.num_tx_ring_entries and self.num_rx_ring_entries
# Provides the number of ring entries for Tx and Rx rings.
# Currently, the code just passes the value to ethtool's --set-ring.
Expand All @@ -70,3 +74,18 @@ def get_base_time_multiple(self):
def supports_schedule(self, schedule):

return True

def default_hints(self):
'''Returns device supported default Hints.
'''
preemption = False
launch_time_control = False
tx_selection_offload = False
datapath = DataPath.AF_PACKET
tx_selection = TxSelection.Qbv

if Capability.Qbv in self.capabilities:
tx_selection_offload = True


return Hints(tx_selection, tx_selection_offload ,datapath, preemption, launch_time_control)
23 changes: 20 additions & 3 deletions detd/devices/intel_i225.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from .device import Capability
from .device import Device

from ..scheduler import DataPath
from ..scheduler import TxSelection
from ..scheduler import Hints

logger = get_logger(__name__)

Expand All @@ -26,7 +29,7 @@ class IntelI225(Device):
NUM_TX_QUEUES = 4
NUM_RX_QUEUES = 4

CAPABILITIES = [Capability.Qbv]
CAPABILITIES = [Capability.Qbv, Capability.LTC, Capability.Qbu]

# Devices supporting TSN: i225-LM, i225-IT
PCI_IDS_VALID = ['8086:0D9F', '8086:15F2']
Expand All @@ -52,11 +55,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.features['rxvlan'] = 'off'
#self.features['hw-tc-offload'] = 'on'

self.capabilities = [Capability.Qbv, Capability.LTC, Capability.Qbu]

# self.num_tx_ring_entries and self.num_rx_ring_entries
# Provides the number of ring entries for Tx and Rx rings.
# Currently, the code just passes the value to ethtool's --set-ring.
Expand Down Expand Up @@ -85,3 +88,17 @@ def supports_schedule(self, schedule):
# FIXME: check additional constraints, like maximum cycle time

return True

def default_hints(self):
'''Returns device supported default Hints.
'''
preemption = False
launch_time_control = False
tx_selection_offload = False
datapath = DataPath.AF_PACKET
tx_selection = TxSelection.Qbv

if Capability.Qbv in self.capabilities:
tx_selection_offload = True

return Hints(tx_selection, tx_selection_offload ,datapath, preemption, launch_time_control)
21 changes: 21 additions & 0 deletions detd/devices/intel_mgbeehl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from .device import Capability
from .device import Device

from ..scheduler import DataPath
from ..scheduler import TxSelection
from ..scheduler import Hints

logger = get_logger(__name__)

Expand Down Expand Up @@ -44,6 +47,7 @@ class IntelMgbeEhl(Device):
# Make sure to expose this in your device class.
PCI_IDS = PCI_IDS_HOST + PCI_IDS_PSE

CAPABILITIES = [Capability.Qbv, Capability.LTC, Capability.Qbu]

# FIXME support for listener stream
# If the stream is time aware, flows should be configured for PTP traffic
Expand All @@ -65,6 +69,8 @@ def __init__(self, pci_id):
self.num_tx_ring_entries = 1024
self.num_rx_ring_entries = 1024

self.capabilities = [Capability.Qbv, Capability.LTC, Capability.Qbu]

# Please note other features are currently set for all devices in the
# systemconf module.
# For example, Energy Efficient Ethernet is disabled for all devices.
Expand All @@ -79,3 +85,18 @@ def supports_schedule(self, schedule):
# FIXME: check additional constraints, like maximum cycle time

return True

def default_hints(self):
'''Returns device supported default Hints.
'''
preemption = False
launch_time_control = False
tx_selection_offload = False
datapath = DataPath.AF_PACKET
tx_selection = TxSelection.Qbv

if Capability.Qbv in self.capabilities:
tx_selection_offload = True


return Hints(tx_selection, tx_selection_offload ,datapath, preemption, launch_time_control)
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
60 changes: 47 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 TxSelection
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 == TxSelection.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,32 @@ 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):

# Get the device suggested default hints
hints = self.interface.device.default_hints()

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

if TxSelection(config.hints.tx_selection) != hints.tx_selection:
raise ValueError(f"Device does not support the requested Tx selection feature."
f"Requested: {TxSelection(config.hints.tx_selection)}, Device Capabilities: {hints.tx_selection}")

if config.hints.launch_time_control != hints.launch_time_control:
raise ValueError(f"Device does not support the requested launch_time_control feature."
f"Requested: {config.hints.launch_time_control}, Device Capabilities: {hints.launch_time_control}")

if config.hints.tx_selection_offload != hints.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: {hints.tx_selection_offload}")

if config.hints.preemption != hints.preemption:
raise ValueError(f"Device does not support the requested preemption feature."
f"Requested: {config.hints.preemption}, Device Capabilities: {hints.preemption}")

return hints
Loading

0 comments on commit 9445d35

Please sign in to comment.