Skip to content

Commit

Permalink
Add Hints class and replace options.
Browse files Browse the repository at this point in the history
Signed-off-by: Kumar <kumar.amber@intel.com>
  • Loading branch information
kamber-intel committed May 9, 2024
1 parent efbfd70 commit 8b9c57c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 36 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"

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
17 changes: 9 additions & 8 deletions detd/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from .scheduler import Scheduler
from .scheduler import Traffic
from .scheduler import TrafficType
from .scheduler import Hints
from .scheduler import TxSelection
from .scheduler import DataPath
from .systemconf import SystemInformation
from .mapping import Mapping
from .common import Check
Expand Down Expand Up @@ -86,7 +89,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,19 +99,17 @@ 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
self.interface = config.interface

if self.options.qdiscmap == "nomap":
self.mapping = Mapping(self.interface)
else:
self.mapping = Mapping(self.interface, self.options)
self.mapping = Mapping(self.interface)
self.scheduler = Scheduler(self.mapping)

# Default parameters for hints.
self.hints = Hints(TxSelection.ENHANCEMENTS_FOR_SCHEDULED_TRAFFIC, False, DataPath.AF_PACKET, True, True)

def add_talker(self, config):
'''
Expand Down
10 changes: 3 additions & 7 deletions detd/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,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 +355,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
61 changes: 56 additions & 5 deletions detd/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import math

from .common import Check
from .common import Options

from .logger import get_logger

Expand All @@ -37,18 +36,20 @@

class Configuration:

def __init__(self, interface, stream, traffic, options = None):
def __init__(self, interface, stream, traffic, hints = None):

if stream.txoffset > traffic.interval:
raise TypeError("Invalid TxOffset, it exceeds Interval")

self.interface = interface
self.stream = stream
self.traffic = traffic
if options is None:
self.options = Options()

# Initialize hints to a default value if None is passed
if hints is None:
self.hints = Hints(TxSelection.ENHANCEMENTS_FOR_SCHEDULED_TRAFFIC, False, DataPath.AF_PACKET, True, True)
else:
self.options = options
self.hints = hints


class StreamConfiguration:
Expand Down Expand Up @@ -389,3 +390,53 @@ def reschedule(self):

self.schedule.add_best_effort_padding(self.traffics[0])
# FIXME: error handling

class TxSelection(enum.Enum):
ENHANCEMENTS_FOR_SCHEDULED_TRAFFIC = 1
STRICT_PRIORITY = 2

class DataPath(enum.Enum):
AF_PACKET = 1
AF_XDP_ZC = 2

class Hints:
"""
A configuration class for managing traffic specifications and QoS (Quality of Service)
settings for network devices.
Attributes:
tx_selection (str): Determines the transmission selection mechanism to use.
Possible values are:
- 'ENHANCEMENTS_FOR_SCHEDULED_TRAFFIC' (802.1Qbv)
- 'STRICT_PRIORITY'
tx_selection_offload (bool): Indicates whether a hardware offload for the
tx_selection mechanism is used. True means hardware offload is enabled,
false implies a software-based approach.
data_path (str): Specifies the data path technology used. Current options include:
- 'AF_PACKET'
- 'AF_XDP_ZC'
Future expansions may include other data paths like 'DPDK'.
preemption (bool): Enables or disables preemption in the data transmission.
launch_time_control (bool): Enables or disables launch time control for packets.
"""
def __init__(self, tx_selection: TxSelection, tx_selection_offload: bool, data_path: DataPath, preemption: bool, launch_time_control: bool):
if not isinstance(tx_selection, TxSelection):
raise ValueError("Invalid value for tx_selection")
if not isinstance(data_path, DataPath):
raise ValueError("Invalid value for data_path")

self.tx_selection = tx_selection
self.tx_selection_offload = tx_selection_offload
self.data_path = data_path
self.preemption = preemption
self.launch_time_control = launch_time_control

def __repr__(self):
return (f"Hints(tx_selection={self.tx_selection.name}, "
f"tx_selection_offload={self.tx_selection_offload}, "
f"data_path={self.data_path.name}, "
f"preemption={self.preemption}, "
f"launch_time_control={self.launch_time_control})")


14 changes: 9 additions & 5 deletions detd/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@
from .scheduler import Configuration
from .scheduler import StreamConfiguration
from .scheduler import TrafficSpecification
from .scheduler import Hints

from .systemconf import Check
from .systemconf import QdiscConfigurator
from .systemconf import DeviceConfigurator
from .systemconf import SystemInformation
from .systemconf import CommandIp

from .common import Options

from .logger import setup_root_logger
from .logger import get_logger

Expand Down Expand Up @@ -249,14 +248,19 @@ def _add_talker(self, request):
interval = request.period
size = request.size
interface_name = request.interface
tx_selection = request.tx_selection
tx_selection_offload = request.tx_selection_offload
data_path = request.data_path
preemption = request.preemption
launch_time_control = request.launch_time_control


options = Options()
options.qdiscmap = request.qdiscmap
interface = Interface(interface_name)
stream = StreamConfiguration(addr, vid, pcp, txoffset)
traffic = TrafficSpecification(interval, size)
hints = Hints(tx_selection, tx_selection_offload, data_path, preemption, launch_time_control)

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

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

Expand Down

0 comments on commit 8b9c57c

Please sign in to comment.