On Mon, Oct 30, 2023 at 02:58:36AM -0400, Mike Pattrick wrote:
> Currently when userspace-tso is enabled, netdev-linux interfaces will
> indicate support for all offload flags regardless of interface
> configuration. This patch checks for which offload features are enabled
> during netdev construction.
> 
> Signed-off-by: Mike Pattrick <m...@redhat.com>

...

> @@ -2381,6 +2376,153 @@ netdev_internal_get_stats(const struct netdev 
> *netdev_,
>      return error;
>  }
>  
> +static int
> +netdev_linux_read_stringset_info(struct netdev_linux *netdev, uint32_t *len)
> +{
> +    /*
> +    struct {
> +        union {
> +            struct ethtool_sset_info hdr;
> +            struct {
> +                uint64_t pad[2];
> +                uint32_t sset_len[1];
> +            };
> +        };
> +    } sset_info;
> +    */

Hi Mike,

maybe the comment above is an artifact that should be removed?

> +    union {
> +        struct ethtool_sset_info hdr;
> +        struct {
> +            uint64_t pad[2];
> +            uint32_t sset_len[1];
> +        };
> +    } sset_info;
> +
> +    sset_info.hdr.cmd = ETHTOOL_GSSET_INFO;
> +    sset_info.hdr.reserved = 0;
> +    sset_info.hdr.sset_mask = 1ULL << ETH_SS_FEATURES;
> +
> +    int error = netdev_linux_do_ethtool(netdev->up.name,
> +            (struct ethtool_cmd *)&sset_info,
> +            ETHTOOL_GSSET_INFO, "ETHTOOL_GSSET_INFO");
> +    if (error) {
> +        return error;
> +    }
> +    *len = sset_info.sset_len[0];
> +    return 0;
> +}
> +
> +
> +static int
> +netdev_linux_read_definitions(struct netdev_linux *netdev,
> +                              struct ethtool_gstrings **pstrings)
> +{
> +    int error = 0;
> +    struct ethtool_gstrings *strings = NULL;
> +    uint32_t len = 0;

Reverse xmas tree please.

> +
> +    error = netdev_linux_read_stringset_info(netdev, &len);
> +    if (error || !len) {
> +        return error;
> +    }
> +    strings = xcalloc(1, sizeof(*strings) + len * ETH_GSTRING_LEN);
> +    if (!strings) {
> +        return ENOMEM;
> +    }
> +
> +    strings->cmd = ETHTOOL_GSTRINGS;
> +    strings->string_set = ETH_SS_FEATURES;
> +    strings->len = len;
> +    error = netdev_linux_do_ethtool(netdev->up.name,
> +            (struct ethtool_cmd *) strings,
> +            ETHTOOL_GSTRINGS, "ETHTOOL_GSTRINGS");
> +    if (error) {
> +        goto out;
> +    }
> +
> +    for (int i = 0; i < len; i++) {
> +        strings->data[(i + 1) * ETH_GSTRING_LEN - 1] = 0;
> +    }
> +
> +    *pstrings = strings;
> +
> +    return 0;
> +out:
> +    *pstrings = NULL;
> +    free(strings);
> +    return error;
> +}
> +
> +static void
> +netdev_linux_set_ol(struct netdev *netdev_)
> +{
> +    struct netdev_linux *netdev = netdev_linux_cast(netdev_);
> +    struct ethtool_gstrings *names = NULL;
> +    struct ethtool_gfeatures *features = NULL;
> +    int error;

Ditto.

...
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to