Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1019932ybh; Wed, 11 Mar 2020 15:49:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsZ4HHofDZjpAiASawNmAdOr9jxOzbBQWowz5yjsYN5sfLZkbF3nE3EwwqeKJO84qQRxgp2 X-Received: by 2002:a4a:e503:: with SMTP id r3mr1879319oot.56.1583966979958; Wed, 11 Mar 2020 15:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583966979; cv=none; d=google.com; s=arc-20160816; b=eQSX+bfJ6z6s0mV7M4iY+jwwJmr3QEpT/NqE7Q4uPvquOgwoZ8nd1d4oAUwlSpnUFu oSd6AX9vZNgEfSv6/f+Zu5GNQuTVN1XcGPNuXsbVV3f0NVBsSonpJzh2ZPun2iq8r2Bn g9t/027FhOoTIv3Sn3W9fBbpY/XU2gd+MpqH3bTaGu+71/iUMyxxQSKVx2K4ZCnflum7 uVluU8lrkxhDUBGvQwucnLTw24mcoEQSWLX0o+hEV3uGcFB6v2dDVctPA2ZHCthVt7Xi 1xjggMNbGrh5GpvUtcLKFY+waLmtfWN+px7wLz1aBKXF4Z47DbyNetmD3CIyq3oQhA1p wrRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=IoIiDGBwf80AMK9+5AIEQtA7nPAWeeTvcl8d/41eAt0=; b=GI49LzQbQMqRrQURzDizWdf/Ic/Dz2NstF8FOaPG4a+bpHnkPf9ut1cX7KfFxm7/dI fY5oJRdrgq0w5DgwqE6IxO4m5akfCayZ9zDDo0h3BYZMQR5GTmjdt+Ljgz40wV+7RrLI 1VHcJYmBVBOHZlT9sKNVXnngYryNY5Ex7g6p0CbaH65dccXb2pnX4yrgjLtlOzA85jEj +hIfkessGadjseZz8rkpuKA2g7snwM+DazfIkO+cGhwUC1BtECq4H2iQsYD8MppKb8FZ RrqG3Wjfhp/cgEqtq5Zyqx0l40PoKYKmuzqAllOHxn7O9GOgvnpoXlr3nnTOHv1uzhn7 1BgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1w/KIC0m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si1920250oti.166.2020.03.11.15.49.28; Wed, 11 Mar 2020 15:49:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1w/KIC0m"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731369AbgCKWtM (ORCPT + 99 others); Wed, 11 Mar 2020 18:49:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:51962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729739AbgCKWtM (ORCPT ); Wed, 11 Mar 2020 18:49:12 -0400 Received: from kicinski-fedora-PC1C0HJN (unknown [163.114.132.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BA6A2206E7; Wed, 11 Mar 2020 22:49:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583966951; bh=XDMWLM9ZHsVTFkpy0uJjXIAczv20ViLNNjhPI5zknsg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=1w/KIC0mZ0s4oZnaEPtBnHleQZ6kopaDqTWirZwjawbTR9KjRTFAFIM88rUl2BTPM OoQuXoXxJ8H39IJx3Zf5bwYtMIFeVPXauFBPYBCwQi7azq+aBm8WZgd5uNd7nTXq/u VrP6MGat6sMTkAEfvs/HGdCjARGgOfSYwhzEaMSo= Date: Wed, 11 Mar 2020 15:49:08 -0700 From: Jakub Kicinski To: Michal Kubecek Cc: David Miller , netdev@vger.kernel.org, Jiri Pirko , Andrew Lunn , Florian Fainelli , John Linville , Johannes Berg , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 03/15] ethtool: provide netdev features with FEATURES_GET request Message-ID: <20200311154908.7fd7047d@kicinski-fedora-PC1C0HJN> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Mar 2020 22:40:18 +0100 (CET) Michal Kubecek wrote: > diff --git a/net/ethtool/common.h b/net/ethtool/common.h > index 40ba74e0b9bb..82211430d3db 100644 > --- a/net/ethtool/common.h > +++ b/net/ethtool/common.h > @@ -6,6 +6,8 @@ > #include > #include > > +#define ETHTOOL_DEV_FEATURE_WORDS ((NETDEV_FEATURE_COUNT + 31) / 32) nit: since this line is touched perhaps worth converting to DIV_ROUND_UP()? > /* compose link mode index from speed, type and duplex */ > #define ETHTOOL_LINK_MODE(speed, type, duplex) \ > ETHTOOL_LINK_MODE_ ## speed ## base ## type ## _ ## duplex ## _BIT > +static void ethnl_features_to_bitmap32(u32 *dest, netdev_features_t src) > +{ > + unsigned int i; > + > + for (i = 0; i < ETHTOOL_DEV_FEATURE_WORDS; i++) > + dest[i] = (u32)(src >> (32 * i)); nit: cast unnecessary > +} > + > +static int features_prepare_data(const struct ethnl_req_info *req_base, > + struct ethnl_reply_data *reply_base, > + struct genl_info *info) > +{ > + struct features_reply_data *data = FEATURES_REPDATA(reply_base); > + struct net_device *dev = reply_base->dev; > + netdev_features_t all_features; > + > + ethnl_features_to_bitmap32(data->hw, dev->hw_features); > + ethnl_features_to_bitmap32(data->wanted, dev->wanted_features); > + ethnl_features_to_bitmap32(data->active, dev->features); > + ethnl_features_to_bitmap32(data->nochange, NETIF_F_NEVER_CHANGE); > + all_features = ~(netdev_features_t)0 >> > + (8 * sizeof(all_features) - NETDEV_FEATURE_COUNT); nit: GENMASK_ULL(NETDEV_FEATURE_COUNT % 32 - 1, 0) ? > + ethnl_features_to_bitmap32(data->all, all_features); > + > + return 0; > +} > +static int features_fill_reply(struct sk_buff *skb, > + const struct ethnl_req_info *req_base, > + const struct ethnl_reply_data *reply_base) > +{ > + const struct features_reply_data *data = FEATURES_REPDATA(reply_base); > + bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; > + int ret; > + > + ret = ethnl_put_bitset32(skb, ETHTOOL_A_FEATURES_HW, data->hw, > + data->all, NETDEV_FEATURE_COUNT, > + netdev_features_strings, compact); > + if (ret < 0) > + return ret; > + ret = ethnl_put_bitset32(skb, ETHTOOL_A_FEATURES_WANTED, data->wanted, > + NULL, NETDEV_FEATURE_COUNT, > + netdev_features_strings, compact); > + if (ret < 0) > + return ret; > + ret = ethnl_put_bitset32(skb, ETHTOOL_A_FEATURES_ACTIVE, data->active, > + NULL, NETDEV_FEATURE_COUNT, > + netdev_features_strings, compact); > + if (ret < 0) > + return ret; > + ret = ethnl_put_bitset32(skb, ETHTOOL_A_FEATURES_NOCHANGE, > + data->nochange, NULL, NETDEV_FEATURE_COUNT, > + netdev_features_strings, compact); > + > + return ret; nit: return directly? > +} Probably not worth respinning for just those nits: Reviewed-by: Jakub Kicinski