DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
To: jspewock@iol.unh.edu, thomas@monjalon.net,
	yoan.picchi@foss.arm.com, paul.szczepanek@arm.com,
	Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu,
	wathsala.vithanage@arm.com, Luca.Vizzarro@arm.com,
	npratte@iol.unh.edu, alex.chapman@arm.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v3 1/1] dts: add text parser for testpmd verbose output
Date: Mon, 9 Sep 2024 13:44:09 +0200	[thread overview]
Message-ID: <3627c429-9a3e-48af-8c42-d85c83ee2998@pantheon.tech> (raw)
In-Reply-To: <20240808203612.329540-2-jspewock@iol.unh.edu>


> diff --git a/dts/framework/parser.py b/dts/framework/parser.py
> index 741dfff821..0b39025a48 100644
> --- a/dts/framework/parser.py
> +++ b/dts/framework/parser.py
> @@ -160,6 +160,36 @@ def _find(text: str) -> Any:
>   
>           return ParserFn(TextParser_fn=_find)
>   
> +    @staticmethod
> +    def find_all(
> +        pattern: str | re.Pattern[str],
> +        flags: re.RegexFlag = re.RegexFlag(0),
> +    ) -> ParserFn:

I'd remove this if it's not used, the rule being let's not introduce 
unused code because it's not going to be maintained. We can always add 
it when needed.

> +        """Makes a parser function that finds all of the regular expression matches in the text.
> +
> +        If there are no matches found in the text than None will be returned, otherwise a list

then None, but maybe a comma would be better (found in the text, None 
will be returned)

> +        containing all matches will be returned. Patterns that contain multiple groups will pack
> +        the matches for each group into a tuple.
> +

> diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
> index 43e9f56517..7d0b5a374c 100644
> --- a/dts/framework/remote_session/testpmd_shell.py
> +++ b/dts/framework/remote_session/testpmd_shell.py
> @@ -31,7 +31,7 @@
>   from framework.settings import SETTINGS
>   from framework.testbed_model.cpu import LogicalCoreCount, LogicalCoreList
>   from framework.testbed_model.sut_node import SutNode
> -from framework.utils import StrEnum
> +from framework.utils import REGEX_FOR_MAC_ADDRESS, StrEnum
>   
>   
>   class TestPmdDevice:
> @@ -577,6 +577,377 @@ class TestPmdPortStats(TextParser):
>       tx_bps: int = field(metadata=TextParser.find_int(r"Tx-bps:\s+(\d+)"))
>   
>   
> +class OLFlag(Flag):

We should come up with a consistent naming scheme for the various 
offloads. In the capabilities patch, I've introduced 
RxOffloadCapability. I think we can use the full word Offload and we 
should also capture in the name what sort of offload it is. In this 
case, would PacketOffloadFlag be a good name?

> +    """Flag representing the Packet Offload Features Flags in DPDK.
> +
> +    Values in this class are taken from the definitions in the RTE MBUF core library in DPDK.

I like the reference, let's also mention the name of the file 
rte_mbuf_core.h. Maybe we should add more references like these to other 
flags.

> +    """
> +
> +    # RX flags
> +    #:
> +    RTE_MBUF_F_RX_RSS_HASH = auto()
> +
> +    #:

I noticed the flags are not sorted the same way as in rte_mbuf_core.h. I 
think there's value in using the same flag values.

We could also add descriptions to the flag if there are some to be found 
in rte_mbuf_core.h.

> +
> +    # TX flags
> +    #:
> +    RTE_MBUF_F_TX_OUTER_UDP_CKSUM = auto()

Since there is a gap between RX and TX flags, you can just assign the 
actual value here (1 << 41) and the continue using auto().


> +    @classmethod
> +    def from_str_list(cls, arr: list[str]) -> Self:
> +        """Makes an instance from a list containing the flag members.
> +
> +        Args:
> +            arr: A list of strings containing ol_flag values.
> +
> +        Returns:
> +            A new instance of the flag.
> +        """
> +        flag = cls(0)
> +        for name in arr:
> +            if name in cls.__members__:

We could also do if cls[name] in cls. It's basically the same thing, but 
doesn't use the dunder method.

> +                flag |= cls[name]
> +        return flag
> +
> +    @classmethod
> +    def make_parser(cls) -> ParserFn:
> +        """Makes a parser function.
> +
> +        Returns:
> +            ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a
> +                parser function that makes an instance of this flag from text.
> +        """
> +        return TextParser.wrap(
> +            TextParser.wrap(TextParser.find(r"ol_flags: ([^\n]+)"), str.split),
> +            cls.from_str_list,
> +        )
> +
> +
> +class RtePTypes(Flag):
> +    """Flag representing possible packet types in DPDK verbose output."""

Now this docstring doesn't reference from where these come from.

I found these in rte_mbuf_ptype.h, but from what I can tell, they're not 
actual flags, just regular numbers:
#define RTE_PTYPE_L2_ETHER                  0x00000001
#define RTE_PTYPE_L2_ETHER_TIMESYNC         0x00000002

etc., so we're basically converting that to flags. I think this is OK 
and we don't really need to concern ourselves with the actual values, 
just the order.


> +    @classmethod
> +    def from_str_list(cls, arr: list[str]) -> Self:
> +        """Makes an instance from a list containing the flag members.
> +
> +        Args:
> +            arr: A list of strings containing ol_flag values.

ol_flag looks like a copy-paste.

> +
> +        Returns:
> +            A new instance of the flag.
> +        """
> +        flag = cls(0)
> +        for name in arr:
> +            if name in cls.__members__:
> +                flag |= cls[name]
> +        return flag
> +
> +    @classmethod
> +    def make_parser(cls, hw: bool) -> ParserFn:
> +        """Makes a parser function.
> +
> +        Args:
> +            hw: Whether to make a parser for hardware ptypes or software ptypes. If :data:`True`

I think there should be a comma before hardware (on the next line).

> +                hardware ptypes will be collected, otherwise software pytpes will.
> +
> +        Returns:
> +            ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a
> +                parser function that makes an instance of this flag from text.
> +        """
> +        return TextParser.wrap(
> +            TextParser.wrap(TextParser.find(f"{'hw' if hw else 'sw'} ptype: ([^-]+)"), str.split),
> +            cls.from_str_list,
> +        )
> +
> +
> +@dataclass
> +class TestPmdVerbosePacket(TextParser):

> +    ol_flags: OLFlag = field(metadata=OLFlag.make_parser())
> +    #: RSS has of the packet in hex.

typo: hash


>   class TestPmdShell(DPDKShell):

> +    @staticmethod
> +    def extract_verbose_output(output: str) -> list[TestPmdVerbosePacket]:
> +        """Extract the verbose information present in given testpmd output.
> +
> +        This method extracts sections of verbose output that begin with the line
> +        "port X/queue Y: sent/received Z packets" and end with the ol_flags of a packet.
> +
> +        Args:
> +            output: Testpmd output that contains verbose information
> +
> +        Returns:
> +            List of parsed packet information gathered from verbose information in `output`.
> +        """
> +        out: list[TestPmdVerbosePacket] = []
> +        prev_header: str = ""
> +        iter = re.finditer(
> +            r"(?P<HEADER>(?:port \d+/queue \d+: received \d packets)?)\s*"

Looks like sent packets won't be captured by this.


> diff --git a/dts/framework/utils.py b/dts/framework/utils.py
> index 6b5d5a805f..9c64cf497f 100644
> --- a/dts/framework/utils.py
> +++ b/dts/framework/utils.py
> @@ -27,6 +27,7 @@
>   from .exception import ConfigurationError
>   
>   REGEX_FOR_PCI_ADDRESS: str = "/[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}.[0-9]{1}/"
> +REGEX_FOR_MAC_ADDRESS: str = r"(?:[\da-fA-F]{2}:){5}[\da-fA-F]{2}"

Is this the only format that testpmd returns?



  parent reply	other threads:[~2024-09-09 11:44 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 20:39 [PATCH v1 0/1] dts: testpmd verbose parser jspewock
2024-07-29 20:39 ` [PATCH v1 1/1] dts: add text parser for testpmd verbose output jspewock
2024-07-30 13:34 ` [PATCH v2 0/1] dts: testpmd verbose parser jspewock
2024-07-30 13:34   ` [PATCH v2 1/1] dts: add text parser for testpmd verbose output jspewock
2024-07-30 15:41     ` Nicholas Pratte
2024-07-30 21:30       ` Jeremy Spewock
2024-08-02 14:54         ` Nicholas Pratte
2024-08-02 17:38           ` Jeremy Spewock
2024-08-05 13:20             ` Nicholas Pratte
2024-07-30 21:33     ` Jeremy Spewock
2024-08-01  8:43       ` Luca Vizzarro
2024-08-02 13:40         ` Jeremy Spewock
2024-08-01  8:41     ` Luca Vizzarro
2024-08-02 13:35       ` Jeremy Spewock
2024-08-08 20:36 ` [PATCH v3 0/1] dts: testpmd verbose parser jspewock
2024-08-08 20:36   ` [PATCH v3 1/1] dts: add text parser for testpmd verbose output jspewock
2024-08-08 21:49     ` Jeremy Spewock
2024-08-12 17:32       ` Nicholas Pratte
2024-09-09 11:44     ` Juraj Linkeš [this message]
2024-09-17 13:40       ` Jeremy Spewock
2024-09-18  8:09         ` Juraj Linkeš
2024-09-18 16:34 ` [PATCH v4 0/1] dts: testpmd verbose parser jspewock
2024-09-18 16:34   ` [PATCH v4 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-18 17:05 ` [PATCH v5 0/1] dts: testpmd verbose parser jspewock
2024-09-18 17:05   ` [PATCH v5 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-19  9:02     ` Juraj Linkeš
2024-09-20 15:53       ` Jeremy Spewock
2024-09-23 13:30         ` Juraj Linkeš
2024-09-19 12:35     ` Juraj Linkeš
2024-09-20 15:55       ` Jeremy Spewock
2024-09-25 15:46 ` [PATCH v6 0/1] dts: testpmd verbose parser jspewock
2024-09-25 15:46   ` [PATCH v6 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-26  8:25     ` Juraj Linkeš
2024-09-26 14:43       ` Jeremy Spewock
2024-09-26 15:47 ` [PATCH v7 0/1] dts: testpmd verbose parser jspewock
2024-09-26 15:47   ` [PATCH v7 1/1] dts: add text parser for testpmd verbose output jspewock
2024-09-27  9:32     ` Juraj Linkeš
2024-09-27 11:48     ` Luca Vizzarro
2024-09-30 13:41     ` Juraj Linkeš

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3627c429-9a3e-48af-8c42-d85c83ee2998@pantheon.tech \
    --to=juraj.linkes@pantheon.tech \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Luca.Vizzarro@arm.com \
    --cc=alex.chapman@arm.com \
    --cc=dev@dpdk.org \
    --cc=jspewock@iol.unh.edu \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=thomas@monjalon.net \
    --cc=wathsala.vithanage@arm.com \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).