On 5/17/23 05:11, Mike Pattrick wrote:
> From: Flavio Leitner <[email protected]>
>
> 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 <[email protected]>
> Co-authored-by: Mike Pattrick <[email protected]>
> Signed-off-by: Mike Pattrick <[email protected]>
> Reviewed-by: David Marchand <[email protected]>
> ---
> 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
> Since v10:
> - No change
> Since v11:
> - Removed depricated documentation
> - Clarified offload direction in status field
> ---
> lib/netdev-dpdk.c | 5 -----
> lib/netdev-provider.h | 1 +
> lib/netdev.c | 30 +++++++++++++++++++++++++++---
> tests/dpif-netdev.at | 18 ++++++++++++++++++
> 4 files changed, 46 insertions(+), 8 deletions(-)
>
> 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. */
What is this comment referring to?
> 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..cc03308fb 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,32 @@ 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, "tx_" 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);
> +#undef OL_ADD_STAT
> + smap_add(smap, "tx_tcp_seg_offload", netdev->ol_flags & \
> + NETDEV_TX_OFFLOAD_TCP_TSO ? "true" : "false");
Don't use line continuation is a normal C code. And it's likely
better to write this way:
smap_add(smap, "tx_tcp_seg_offload",
(netdev->ol_flags & NETDEV_TX_OFFLOAD_TCP_TSO)
? "true" : "false");
Or the macro can be re-used by moving the '_csum' part to the 'name'.
> +
> + 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..60d789beb 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 tx packet checksum offloading])
> +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 get interface p1 status | sed -n 's/^{\(.*\).*}$/\1/p'],
> [0], [dnl
> +tx_ip_csum_offload="false", tx_sctp_csum_offload="false",
> tx_tcp_csum_offload="false", tx_tcp_seg_offload="false",
> tx_udp_csum_offload="false"
> +], [])
> +
> +AT_CHECK([ovs-vsctl get interface br0 status | sed -n
> 's/^{\(.*\).*}$/\1/p'], [0], [dnl
> +tx_ip_csum_offload="false", tx_sctp_csum_offload="false",
> tx_tcp_csum_offload="false", tx_tcp_seg_offload="false",
> tx_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.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev