From: Flavio Leitner <f...@sysclose.org> This patch modifies netdev_get_status to include information about checksum offload status by port, allowing the user to gain insight into where checksum offloading is active.
Signed-off-by: Flavio Leitner <f...@sysclose.org> Co-authored-by: Mike Pattrick <m...@redhat.com> Signed-off-by: Mike Pattrick <m...@redhat.com> --- Since v9: - Removed entire ovs-appctl dpif-netdev/offload-show command, replaced with a field in the netdev status. - Removed duplicative field tx_tso_offload from netdev-dpdk.c --- lib/dpif-netdev-unixctl.man | 6 ++++++ lib/netdev-dpdk.c | 5 ----- lib/netdev-provider.h | 1 + lib/netdev.c | 29 ++++++++++++++++++++++++++--- tests/dpif-netdev.at | 18 ++++++++++++++++++ 5 files changed, 51 insertions(+), 8 deletions(-) diff --git a/lib/dpif-netdev-unixctl.man b/lib/dpif-netdev-unixctl.man index 8cd847416..2840d462e 100644 --- a/lib/dpif-netdev-unixctl.man +++ b/lib/dpif-netdev-unixctl.man @@ -262,3 +262,9 @@ PMDs in the case where no value is specified. By default "scalar" is used. \fIstudy_cnt\fR defaults to 128 and indicates the number of packets that the "study" miniflow implementation must parse before choosing an optimal implementation. +. +.IP "\fBdpif-netdev/offload-show\fR [\fIdp\fR] [\fInetdev\fR]" +Prints the hardware offloading features enabled in netdev \fInetdev\fR +attached to datapath \fIdp\fR. The datapath \fIdp\fR parameter can be +omitted if there is only one. All netdev ports are printed if the +parameter \fInetdev\fR is omitted. diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index fb0dd43f7..560694dbc 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1753,11 +1753,6 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) } else { smap_add(args, "rx_csum_offload", "false"); } - if (dev->hw_ol_features & NETDEV_TX_TSO_OFFLOAD) { - smap_add(args, "tx_tso_offload", "true"); - } else { - smap_add(args, "tx_tso_offload", "false"); - } smap_add(args, "lsc_interrupt_mode", dev->lsc_interrupt_mode ? "true" : "false"); diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index b5420947d..fcf52bdd9 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -37,6 +37,7 @@ extern "C" { struct netdev_tnl_build_header_params; #define NETDEV_NUMA_UNSPEC OVS_NUMA_UNSPEC +/* Keep this enum updated with translation to string below. */ enum netdev_ol_flags { NETDEV_TX_OFFLOAD_IPV4_CKSUM = 1 << 0, NETDEV_TX_OFFLOAD_TCP_CKSUM = 1 << 1, diff --git a/lib/netdev.c b/lib/netdev.c index c79778378..818589246 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -43,6 +43,7 @@ #include "netdev-provider.h" #include "netdev-vport.h" #include "odp-netlink.h" +#include "openvswitch/json.h" #include "openflow/openflow.h" #include "packets.h" #include "openvswitch/ofp-print.h" @@ -1373,9 +1374,31 @@ netdev_get_next_hop(const struct netdev *netdev, int netdev_get_status(const struct netdev *netdev, struct smap *smap) { - return (netdev->netdev_class->get_status - ? netdev->netdev_class->get_status(netdev, smap) - : EOPNOTSUPP); + int err = EOPNOTSUPP; + + /* Set offload status only if relevant. */ + if (netdev_get_dpif_type(netdev) && + strcmp(netdev_get_dpif_type(netdev), "system")) { + +#define OL_ADD_STAT(name, bit) \ + smap_add(smap, name "_csum_offload", \ + netdev->ol_flags & bit ? "true" : "false"); + + OL_ADD_STAT("ip", NETDEV_TX_OFFLOAD_IPV4_CKSUM); + OL_ADD_STAT("tcp", NETDEV_TX_OFFLOAD_TCP_CKSUM); + OL_ADD_STAT("udp", NETDEV_TX_OFFLOAD_UDP_CKSUM); + OL_ADD_STAT("sctp", NETDEV_TX_OFFLOAD_SCTP_CKSUM); + OL_ADD_STAT("tso", NETDEV_TX_OFFLOAD_TCP_TSO); +#undef OL_ADD_STAT + + err = 0; + } + + if (!netdev->netdev_class->get_status) { + return err; + } + + return netdev->netdev_class->get_status(netdev, smap); } /* Returns all assigned IP address to 'netdev' and returns 0. diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at index baab60a22..8a663a4b6 100644 --- a/tests/dpif-netdev.at +++ b/tests/dpif-netdev.at @@ -650,6 +650,24 @@ AT_CHECK([ovs-appctl revalidator/resume]) OVS_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([dpif-netdev - check dpif-netdev/offload-show]) +OVS_VSWITCHD_START( + [add-port br0 p1 \ + -- set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock \ + -- set bridge br0 datapath-type=dummy \ + other-config:datapath-id=1234 fail-mode=secure]) + +AT_CHECK([ovs-vsctl list interface p1 | sed -n 's/^status.*{\(.*\).*}$/\1/p'], [0], [dnl +ip_csum_offload="false", sctp_csum_offload="false", tcp_csum_offload="false", tso_csum_offload="false", udp_csum_offload="false" +], []) + +AT_CHECK([ovs-vsctl list interface br0 | sed -n 's/^status.*{\(.*\).*}$/\1/p'], [0], [dnl +ip_csum_offload="false", sctp_csum_offload="false", tcp_csum_offload="false", tso_csum_offload="false", udp_csum_offload="false" +], []) + +OVS_VSWITCHD_STOP +AT_CLEANUP + # SEND_UDP_PKTS([p_name], [p_ofport]) # # Sends 128 packets to port 'p_name' with different UDP destination ports. -- 2.31.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev