Re: [PATCH 2/5] Split out virNetDevGetEthtoolFeatures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 06, 2016 at 09:39:25 +0200, Ján Tomko wrote:
> Split out the features that we probe via various ethtool commands
> and ETHTOOL_GFLAGS.
> ---
>  src/util/virnetdev.c | 105 ++++++++++++++++++++++++++++-----------------------
>  1 file changed, 57 insertions(+), 48 deletions(-)
> 
> diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
> index 354e6f7..210fcda 100644
> --- a/src/util/virnetdev.c
> +++ b/src/util/virnetdev.c
> @@ -3266,6 +3266,62 @@ virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd)
>  }
>  
>  
> +static void
> +virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
> +                            const char *ifname)
> +{
> +    size_t i;
> +    struct ethtool_value cmd = { 0 };
> +
> +    /* legacy ethtool getters */
> +    struct ethtool_to_virnetdev_feature ethtool_cmds[] = {
> +        {ETHTOOL_GRXCSUM, VIR_NET_DEV_FEAT_GRXCSUM},
> +        {ETHTOOL_GTXCSUM, VIR_NET_DEV_FEAT_GTXCSUM},
> +        {ETHTOOL_GSG, VIR_NET_DEV_FEAT_GSG},
> +        {ETHTOOL_GTSO, VIR_NET_DEV_FEAT_GTSO},
> +# if HAVE_DECL_ETHTOOL_GGSO
> +        {ETHTOOL_GGSO, VIR_NET_DEV_FEAT_GGSO},
> +# endif
> +# if HAVE_DECL_ETHTOOL_GGRO
> +        {ETHTOOL_GGRO, VIR_NET_DEV_FEAT_GGRO},
> +# endif
> +    };
> +
> +# if HAVE_DECL_ETHTOOL_GFLAGS
> +    /* ethtool masks */
> +    struct ethtool_to_virnetdev_feature flags[] = {
> +#  if HAVE_DECL_ETH_FLAG_LRO
> +        {ETH_FLAG_LRO, VIR_NET_DEV_FEAT_LRO},
> +#  endif
> +#  if HAVE_DECL_ETH_FLAG_TXVLAN
> +        {ETH_FLAG_RXVLAN, VIR_NET_DEV_FEAT_RXVLAN},
> +        {ETH_FLAG_TXVLAN, VIR_NET_DEV_FEAT_TXVLAN},
> +#  endif
> +#  if HAVE_DECL_ETH_FLAG_NTUBLE
> +        {ETH_FLAG_NTUPLE, VIR_NET_DEV_FEAT_NTUPLE},
> +#  endif
> +#  if HAVE_DECL_ETH_FLAG_RXHASH
> +        {ETH_FLAG_RXHASH, VIR_NET_DEV_FEAT_RXHASH},
> +#  endif
> +    };
> +
> +    for (i = 0; i < ARRAY_CARDINALITY(ethtool_cmds); i++) {

This is guarded by HAVE_DECL_ETHTOOL_GFLAGS so it is not equivalent to
the code below.

> +        cmd.cmd = ethtool_cmds[i].cmd;
> +        if (virNetDevFeatureAvailable(ifname, &cmd) == 1)
> +            ignore_value(virBitmapSetBit(bitmap, ethtool_cmds[i].feat));
> +    }
> +
> +    cmd.cmd = ETHTOOL_GFLAGS;
> +    if (virNetDevFeatureAvailable(ifname, &cmd) == 1) {
> +        for (i = 0; i < ARRAY_CARDINALITY(flags); i++) {
> +            if (cmd.data & flags[i].cmd)
> +                ignore_value(virBitmapSetBit(bitmap, flags[i].feat));
> +        }
> +    }
> +# endif
> +}

ACK if you move the first loop out of HAVE_DECL_ETHTOOL_GFLAGS but you
need to keep the second one in place.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]