diff mbox series

[ovs-dev,v3,2/2] netdev-dummy: Add support and test for tso.

Message ID 20231219043358.1535269-2-mkp@redhat.com
State Superseded
Headers show
Series [ovs-dev,v3,1/2] dp-packet: Set checksum flags during software TSO. | expand

Checks

Context Check Description
ovsrobot/apply-robot fail apply and check: fail
ovsrobot/intel-ovs-compilation fail test: fail

Commit Message

Mike Pattrick Dec. 19, 2023, 4:33 a.m. UTC
Test that netdev-dummy is able to send and receive segment offloaded
packets.

Signed-off-by: Mike Pattrick <mkp@redhat.com>
---
v2: Fix clang build error: mutex needed to access netdev_dummy members
v3: Remove use of tcpdump, hexdump, and otherwise clean up test
Note, somehow the v3 patch reported as corrupted in patchwork, but it
applied fine for me, trying to resubmit.
---
 lib/netdev-dummy.c   | 32 +++++++++++++++++++++++++++++++-
 tests/dpif-netdev.at | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 1 deletion(-)

+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 AT_SETUP([dpif-netdev - revalidators handle dp modification fail correctly])
 OVS_VSWITCHD_START(
   [add-port br0 p1 \

Comments

0-day Robot Dec. 19, 2023, 4:41 a.m. UTC | #1
Bleep bloop.  Greetings Mike Pattrick, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


git-am:
error: corrupt patch at line 159
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 netdev-dummy: Add support and test for tso.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


Patch skipped due to previous failure.

Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 8c6e6d448..9d9a28892 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -44,6 +44,7 @@ 
 #include "unaligned.h"
 #include "timeval.h"
 #include "unixctl.h"
+#include "userspace-tso.h"
 #include "reconnect.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_dummy);
@@ -152,6 +153,8 @@  struct netdev_dummy {
     bool ol_ip_csum OVS_GUARDED;
     /* Flag RX packet with good csum. */
     bool ol_ip_csum_set_good OVS_GUARDED;
+    /* Set the segment size for netdev TSO support. */
+    int ol_tso_segsz OVS_GUARDED;
 };
 
 /* Max 'recv_queue_len' in struct netdev_dummy. */
@@ -806,6 +809,10 @@  netdev_dummy_get_config(const struct netdev *dev, struct smap *args)
         smap_add_format(args, "ol_ip_csum_set_good", "%s", "true");
     }
 
+    if (netdev->ol_tso_segsz && userspace_tso_enabled()) {
+        smap_add_format(args, "ol_tso_segsz", "%d", netdev->ol_tso_segsz);
+    }
+
     /* 'dummy-pmd' specific config. */
     if (!netdev_is_pmd(dev)) {
         goto exit;
@@ -937,6 +944,14 @@  netdev_dummy_set_config(struct netdev *netdev_, const struct smap *args,
         netdev_->ol_flags |= NETDEV_TX_OFFLOAD_IPV4_CKSUM;
     }
 
+    if (userspace_tso_enabled()) {
+        netdev->ol_tso_segsz = smap_get_int(args, "ol_tso_segsz", 0);
+        if (netdev->ol_tso_segsz) {
+            netdev_->ol_flags |= (NETDEV_TX_OFFLOAD_TCP_TSO
+                                  | NETDEV_TX_OFFLOAD_TCP_CKSUM);
+        }
+    }
+
     netdev_change_seq_changed(netdev_);
 
     /* 'dummy-pmd' specific config. */
@@ -1119,6 +1134,15 @@  netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet_batch *batch,
         /* The netdev hardware sets the flag when the packet has good csum. */
         dp_packet_ol_set_ip_csum_good(packet);
     }
+
+    if (userspace_tso_enabled() && netdev->ol_tso_segsz) {
+        dp_packet_set_tso_segsz(packet, netdev->ol_tso_segsz);
+        dp_packet_hwol_set_tcp_seg(packet);
+        dp_packet_hwol_set_tx_ip_csum(packet);
+        dp_packet_hwol_set_tx_ipv4(packet);
+        dp_packet_hwol_set_csum_tcp(packet);
+    }
+
     ovs_mutex_unlock(&netdev->mutex);
 
     dp_packet_batch_init_packet(batch, packet);
@@ -1174,6 +1198,12 @@  netdev_dummy_send(struct netdev *netdev, int qid,
     DP_PACKET_BATCH_FOR_EACH(i, packet, batch) {
         const void *buffer = dp_packet_data(packet);
         size_t size = dp_packet_size(packet);
+        bool is_tso;
+
+        ovs_mutex_lock(&dev->mutex);
+        is_tso = userspace_tso_enabled() && dev->ol_tso_segsz &&
+                 dp_packet_hwol_is_tso(packet);
+        ovs_mutex_unlock(&dev->mutex);
 
         if (!dp_packet_is_eth(packet)) {
             error = EPFNOSUPPORT;
@@ -1194,7 +1224,7 @@  netdev_dummy_send(struct netdev *netdev, int qid,
             if (eth->eth_type == htons(ETH_TYPE_VLAN)) {
                 max_size += VLAN_HEADER_LEN;
             }
-            if (size > max_size) {
+            if (size > max_size && !is_tso) {
                 error = EMSGSIZE;
                 break;
             }
diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at
index d0359b5ea..dc6e209b1 100644
--- a/tests/dpif-netdev.at
+++ b/tests/dpif-netdev.at
@@ -810,6 +810,49 @@  AT_CHECK_UNQUOTED([tail -n 1 p2.pcap.txt], [0], [${good_expected}
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([userspace offload - tso])
+OVS_VSWITCHD_START(
+  [set Open_vSwitch . other_config:userspace-tso-enable=true -- \
+   add-br br1 -- set bridge br1 datapath-type=dummy -- \
+   add-port br1 p1 -- \
+       set Interface p1 type=dummy -- \
+   add-port br1 p2 -- \
+       set Interface p2 type=dummy])
+
+dnl Simple passthrough rule.
+AT_CHECK([ovs-ofctl add-flow br1 in_port=p1,actions=output:p2])
+
+flow_s="in_port(1),eth(src=8a:bf:7e:2f:05:84,dst=0a:8f:39:4f:e0:73),eth_type(0x0800), \
+        ipv4(src=192.168.123.2,dst=192.168.123.1,proto=6,tos=1,ttl=64,frag=no), \
+        tcp(src=54392,dst=5201),tcp_flags(ack)"
+
+dnl Send from tso to no-tso.
+AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap -- \
+                    set Interface p1 options:ol_ip_csum=true -- \
+                    set Interface p1 options:ol_ip_csum_set_good=false -- \
+                    set Interface p1 options:ol_tso_segsz=500])
+
+AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s}" --len 2054])
+
+dnl Send from tso to tso.
+AT_CHECK([ovs-vsctl set Interface p2 options:ol_ip_csum=true -- \
+                    set Interface p2 options:ol_ip_csum_set_good=false -- \
+                    set Interface p2 options:ol_tso_segsz=500])
+
+AT_CHECK([ovs-appctl netdev-dummy/receive p1 "${flow_s}" --len 2054])
+
+dnl Check that first we have 4x 500 byte payloads, then one 2000 byte payload.
+AT_CHECK([ovs-pcap p2.pcap], [0], [dnl
+0a8f394fe0738abf7e2f058408004501021c0000000040060187c0a87b02c0a87b01d47814510000000000000000501000004dc200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+0a8f394fe0738abf7e2f058408004501021c0001000040060186c0a87b02c0a87b01d4781451000001f400000000501000004bce00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+0a8f394fe0738abf7e2f058408004501021c0002000040060185c0a87b02c0a87b01d4781451000003e8000000005010000049da00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+0a8f394fe0738abf7e2f058408004501021c0003000040060184c0a87b02c0a87b01d4781451000005dc000000005010000047e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+0a8f394fe0738abf7e2f05840800450107f8000000004006fbaac0a87b02c0a87b01d478145100000000000000005010000047e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000