The subject for this commit should likely explain that this patch adds
the VLAN test suite rather than refacoring it. This sort of falls in
line with what I mentioned  on the previous patch about the commit
messages being about what the entire patch adds rather than the
difference from the last version.

Additionally, I think you will find that a lot of my comments on the
previous version of this commit [1] still apply, but I'll try to point
out anything I didn't mention there in this email.

[1] 
http://inbox.dpdk.org/dev/caaa20utssnb-t-ty+qpwjaz_hrj1jx9htm_kp_utnbynppb...@mail.gmail.com/

On Tue, Jun 18, 2024 at 12:30 PM Dean Marx <dm...@iol.unh.edu> wrote:
>
> Tweaked logic on sending and verifying packets for
> more concise code, added verbose and promisc
> function calls from pmd shell module.

I mentioned this in more detail in the previous patch, but these
descriptions should be more about what the entire patch adds than a
change log from the previous.

>
> Signed-off-by: Dean Marx <dm...@iol.unh.edu>
> ---
>  dts/tests/TestSuite_vlan.py | 167 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 167 insertions(+)
>  create mode 100644 dts/tests/TestSuite_vlan.py
>
<snip>
> +
> +class TestVlan(TestSuite):
> +    """DPDK VLAN test suite.
> +
> +    Ensures VLAN packet reception on the Poll Mode Driver when certain 
> conditions are met.
> +    If one or more of these conditions are not met, the packet reception 
> should be unsuccessful.

The conditions should probably be stated here again briefly, and this
doc-string can go more in depth about how the testing is done than the
module which might help explain the test. You can also touch more here
on what specific cases you are testing.

> +    """
> +
<snip>
> +    def send_vlan_packet_and_verify(
> +        self, should_receive: bool = True, strip: bool = False, vlan_id: int 
> = -1
> +    ) -> None:
> +        """Generate a vlan packet, send and verify on the dut.

It probably makes more sense to call this a SUT rather than DUT since
SUT is what we call it elsewhere in the code.

> +
> +        Args:
> +            should_receive: indicate whether the packet should be 
> successfully received
> +            vlan_id: expected vlan ID
> +            strip: indicates whether stripping is on or off,
> +            and when the vlan tag is checked for a match
> +        """
> +        packet = Ether() / Dot1Q(vlan=vlan_id) / Raw(load='xxxxx')

It looks like you are using this payload to filter the received
packets but that might not be immediately obvious to other developers.
A comment about what this is for might help make it more clear.

Additionally, since this same filter is used later to check if you
captured the packet you are looking for, it is probably better to pull
this out into a seperate variable so it is only hard-coded in one
place.

> +        received_packets = self.send_packet_and_capture(packet)
> +        test_packet = None
> +        for packet in received_packets:
> +            if packet.haslayer(Raw) and packet[Raw].load == b'xxxxx':
> +                test_packet = packet
> +                break

I said in the previous version you could use filter() to shrink the
list, if you just want to find one that matches like this you could
instead use the built in function called any() in python to get a
boolean on if the packet exists or not. It does essentially the same
thing you are doing but is a little more concise.

I did something similar with the any function in this patch:
https://patchwork.dpdk.org/project/dpdk/patch/20240613181510.30135-5-jspew...@iol.unh.edu/

> +        if should_receive:
> +            self.verify(
> +                test_packet is not None, "Packet was dropped when it should 
> have been received"
> +            )
> +            if strip:
> +                self.verify(Dot1Q not in test_packet, "Vlan tag was not 
> stripped successfully")
> +            else:
> +                    self.verify(
> +                        test_packet.vlan == vlan_id, "The received tag did 
> not match the expected tag"
> +                    )
> +        else:
> +            self.verify(
> +                test_packet is None,
> +                "Packet was received when it should have been dropped",
> +            )
> +
> +    def send_packet_and_verify_insertion(self, expected_id: int = -1) -> 
> None:
> +        """Generate a packet with no vlan tag, send and verify on the dut.
> +
> +        Args:
> +            expected_id: the vlan id that is being inserted through 
> tx_offload configuration
> +            should_receive: indicate whether the packet should be 
> successfully received
> +        """
> +        packet = Ether() / Raw(load='xxxxx')

We could do the same thing here with pulling out the filtering into
its own variable.

> +        received_packets = self.send_packet_and_capture(packet)
> +        test_packet = None
> +        for packet in received_packets:
<snip>
> 2.44.0
>

Reply via email to