Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp307047ybh; Thu, 12 Mar 2020 02:20:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvYxJ1kbRlPg9QsrnGXdd5hJwDnK47/RG/zk6tMmErq89KRBclM8+NjHqucZLQaK5wow6vB X-Received: by 2002:aca:7517:: with SMTP id q23mr1837540oic.23.1584004841635; Thu, 12 Mar 2020 02:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584004841; cv=none; d=google.com; s=arc-20160816; b=nqj99945BDKyyUzD652zTglWwG6cZ4JwPEB0WOsNEKqQAN6pKzaBnLgIgEO8oScQeF 1UJPTcBwy+SawAGVOd0KrvE4SfHrd5vJQmnO+ZZH8NHDBvU/H6OiATGlHK5ujTNH6bXX sW+qf5i5jl7oPt6ubxE56HtbcuLCfjCOKsLzdP55aGFju587xoD+rav0oN3lC/5fAqC8 NDL6+sHwYln04RrdBn5Gs4YaWP/dmVEZ3o4uOqOMipNZmp3XYBqsEhmhlzpIZNxA+uwC bm2ycCuqAVly+8fdMGGRhwvPSbx7J4bgbJAfkxiWF3HcvDQocXo/oKBrU8ZZLltLAvXS Q4hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CzQfWUYZwguxHd1GYgSuABBYsOmNQc3Dso1gJ/IYYyg=; b=XBuDKHPvCRJXCgsrTnUnUTtaOMzLqDtQn3WON0QcIx2bJEohwyC9FtTpeFdDBpbMso wW7JqDdXon3ZKyxKSvLZDGaZWJs+igtLfDdWB/d5BXFdxvAXTrvKartEC2yQFB9fmDsI AvT0E0a7LKEoK4OyEWU9QVHY3fwmuwwEwe+Ls4R+LQAmuHoDPCESacVWYHCK++IE2Lxb Czv0X1O7u73ZYrJVf1S1gUwN4MltyLhoxSvVv2IZrhc9zUZf5HUebJZOzQHqynG0nQ9N 2N6yN6LTX7yptZeOuFtiz/yms1aTGB3pQ6ufhW5PdkDAL7asoeq8+tuPDDWqyUYnhvxU h9wg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j69si2506826oib.93.2020.03.12.02.20.29; Thu, 12 Mar 2020 02:20:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726695AbgCLJTu (ORCPT + 99 others); Thu, 12 Mar 2020 05:19:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:49584 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgCLJTt (ORCPT ); Thu, 12 Mar 2020 05:19:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6B79AAC67; Thu, 12 Mar 2020 09:19:47 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 94220E0C79; Thu, 12 Mar 2020 10:19:43 +0100 (CET) Date: Thu, 12 Mar 2020 10:19:43 +0100 From: Michal Kubecek To: netdev@vger.kernel.org Cc: Jakub Kicinski , David Miller , 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: <20200312091943.GK8012@unicorn.suse.cz> References: <20200311154908.7fd7047d@kicinski-fedora-PC1C0HJN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200311154908.7fd7047d@kicinski-fedora-PC1C0HJN> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 03:49:08PM -0700, Jakub Kicinski wrote: > On Wed, 11 Mar 2020 22:40:18 +0100 (CET) Michal Kubecek wrote: > > > > +#define ETHTOOL_DEV_FEATURE_WORDS ((NETDEV_FEATURE_COUNT + 31) / 32) > > nit: since this line is touched perhaps worth converting to > DIV_ROUND_UP()? Yes. > > + for (i = 0; i < ETHTOOL_DEV_FEATURE_WORDS; i++) > > + dest[i] = (u32)(src >> (32 * i)); > > nit: cast unnecessary OK. > > + all_features = ~(netdev_features_t)0 >> > > + (8 * sizeof(all_features) - NETDEV_FEATURE_COUNT); > > nit: GENMASK_ULL(NETDEV_FEATURE_COUNT % 32 - 1, 0) ? Nice, I wasn't aware of this macro. But unless I want to fill data->all directly, it would be without the "% 32" part. > > +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? Ah, right. I eliminated "if (ret < 0)" but did not check again. Michal