Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp328946imp; Thu, 21 Feb 2019 02:15:33 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib9AILsFCROjMMjWbjHodUi60QpohDddcZEwRX/xUAocf3ZZ3bOgR0PvSgv1V38UVbvrBiB X-Received: by 2002:a17:902:b402:: with SMTP id x2mr41443352plr.53.1550744133528; Thu, 21 Feb 2019 02:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550744133; cv=none; d=google.com; s=arc-20160816; b=fFhWpp6XyEMu855C4+1L9D/E50cHtikFO5pQazCY+KgoXuJEInyJZHCCwifgnI5s4p sUuxYVLj9c6JD7B47LCNXLx+BBrl44hC64Ax7Kk8GJ27x3zkb88pUntaKJr72jVKqWB6 sDriUki9jjCBoHGifUXHJs8ip88/F1tuqFSurDlHQzIMY/9DgaDIHSDYAipCX+Ez/zZ4 AOlyqwZDFb/GFBQ4IhpLJkI2Rd3JhzgRWueaMM5Gi1DyH7Yy8LBQ+4Y6qrlggRwX7vx1 8BjrMVkoBVXmvfZCDrfB1h9I27r4eVy6sq0lYTEtw+hUfHAkG1ezCRqr+8J/uMrbNu2k cHgQ== 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=61LtgpDCw23xg98Zr8eaEXBNdhRuHLjnIRoJvH6lzuQ=; b=RN8AMM2aZioKztqwKzBtVnqmZHTB001Danlglbp7YcTHYl6/yfWa4tg1EiViW1uJmC Ncuv6DeoqXj9S5u5fmqUHfIi6R9zxYJjn+CA+9I/rvHG5GF1UZ3F5quNpBH6++qRk5M1 10Biufx/sPbO4vF/VkcZ7hDawo4w9HV3wp78+ov0ix2tc57266g+ebk55nbRbJ22STmU EkMq0aGp12m5Vi9mkVxU5y08vq72RdJDB8zoQBBU5DU6HwrwRDH0P4yNeTBX0eBQ/dYm wNYmLFjcc20Pw/4iZ8bNJ2q+23SrGVpDj5UAK/OVIH+zjQggoyqBDAOI9ASLE/eLa2ap vJmw== 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 d16si15361894pll.236.2019.02.21.02.15.17; Thu, 21 Feb 2019 02:15:33 -0800 (PST) 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 S1727401AbfBUKO1 (ORCPT + 99 others); Thu, 21 Feb 2019 05:14:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:59270 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725943AbfBUKO1 (ORCPT ); Thu, 21 Feb 2019 05:14:27 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E5708AD98; Thu, 21 Feb 2019 10:14:25 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 4E631E00A5; Thu, 21 Feb 2019 11:14:25 +0100 (CET) Date: Thu, 21 Feb 2019 11:14:25 +0100 From: Michal Kubecek To: Florian Fainelli Cc: netdev@vger.kernel.org, David Miller , Andrew Lunn , Jakub Kicinski , Jiri Pirko , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH net-next v3 15/21] ethtool: provide link settings and link modes in GET_SETTINGS request Message-ID: <20190221101425.GO23151@unicorn.suse.cz> References: <00e931c1ecd29bf302a190c7d7a3f2cbd0388542.1550513384.git.mkubecek@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, Feb 20, 2019 at 07:14:50PM -0800, Florian Fainelli wrote: > On 2/18/2019 10:22 AM, Michal Kubecek wrote: > > +#define ETH_SETTINGS_IM_LINKINFO 0x01 > > +#define ETH_SETTINGS_IM_LINKMODES 0x02 > > + > > +#define ETH_SETTINGS_IM_ALL 0x03 > > You could define ETH_SETTINGS_IM_ALL as: > > #define ETH_SETTING_IM_ALL \ > (ETH_SETTINGS_IM_LINKINFO | > ETH_SETTINGS_IM_LINMODES) > > that would scale better IMHO, especially given that you have to keep > bumping that mask with new bits in subsequent patches. I'm considering going even further and using something similar to what is used for NETIF_F_* constants so that the *_ALL value would be calculated automatically. But I'm not sure if it's not too fancy for a uapi header file. > > + if (tb[ETHA_SETTINGS_INFOMASK]) > > + req_info->req_mask = nla_get_u32(tb[ETHA_SETTINGS_INFOMASK]); > > + if (tb[ETHA_SETTINGS_COMPACT]) > > + req_info->compact = true; > > + if (req_info->req_mask == 0) > > + req_info->req_mask = ETH_SETTINGS_IM_ALL; > > What if userland is newer than the kernel and specifies a req_mask with > bits set that you don't support? Should not you always do an & > ETH_SETTINGS_IM_ALL here? In that case only known bits would be handled and the check at the end of prepare_info() would add a warning to extack that part of the information couldn't be provided (same as if some of the recognized parts didn't have necessary ethtool_ops handlers or if they failed). Michal