Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp169470pxb; Wed, 18 Nov 2020 20:18:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYxJahG6/pgJMQs3kkRRYZwgyo0uDOIn7ZnWLVeuk9fyPOoKbsENjbmJvHhaMmLkEPQMDx X-Received: by 2002:a17:906:48c1:: with SMTP id d1mr26517271ejt.123.1605759480456; Wed, 18 Nov 2020 20:18:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605759480; cv=none; d=google.com; s=arc-20160816; b=jOEi3O8im8afbFUuNuHUbEtQhg1MpZQc6HNt4TiJVGGJh1TeC4upoZS85XxnJmuUK4 7j8YfJYeFSKm9EfLT9dwneM7eBXzaVT31pWBQ8EgmKJ4JnYOfqHQDK98b8wyGGVuxIBF u5o8juVd5/M2cmHV46aRVNDNf4VA4SgFTe27WkBtRxAfMdNvFaxo3g1rFD2r2EiE/fto dVtKqtsa5ZGGuAcFaUDq4OmkAnLCGtrqs97HjUHU+hHOojnr89tglWwW649R53L2N5SP lpqr/hXEDyysmnNQtLoqQT45s69fiNbcKDzSecoy7jb89Z6sArlYh7uRGp+WpJNAEVcv V1Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=HWQfmE5d930KV8MNtOE3WKybYVJbvRAIZIoqcaC3Zos=; b=WfcPFrgwYC2OJkp7lnisdzk94AQjzIttzsN80WYZE4rlhIprw14sWSJ2uacokdBlcF Yh06favSHZMn+W7py7Eg1XDWxrKX3Pwvs4M+YZDflDBlqk1IVznWGz2wNVrbQextZ5Ml wkY0OTsQboBcTaZIvg/SHFOfoaqQ/97IYw03R1mAHFb+u3Cp2j7PRCGNHKxGOQ7iv13P UHgXB4sTwgOl/VCsAtJrC4/FWC0/wqNvPOYojR0cnOB3CYuGOtDhMEw0aH/uBtLWQPpv dycRG4NOLJJsoJ9iObVq2qMn/HGq8QkgUxo9NmfDHcoQgN3z1xTuFgG43F38jdrf4c6x SVjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si4041260ejj.520.2020.11.18.20.17.34; Wed, 18 Nov 2020 20:18:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbgKSEQC (ORCPT + 99 others); Wed, 18 Nov 2020 23:16:02 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:37340 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbgKSEQB (ORCPT ); Wed, 18 Nov 2020 23:16:01 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kfbMT-007rUA-A7; Thu, 19 Nov 2020 05:15:57 +0100 Date: Thu, 19 Nov 2020 05:15:57 +0100 From: Andrew Lunn To: Huazhong Tan Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, kuba@kernel.org Subject: Re: [RFC net-next 1/2] ethtool: add support for controling the type of adaptive coalescing Message-ID: <20201119041557.GR1804098@lunn.ch> References: <1605758050-21061-1-git-send-email-tanhuazhong@huawei.com> <1605758050-21061-2-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1605758050-21061-2-git-send-email-tanhuazhong@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h > index 9ca87bc..afd8de2 100644 > --- a/include/uapi/linux/ethtool.h > +++ b/include/uapi/linux/ethtool.h > @@ -433,6 +433,7 @@ struct ethtool_modinfo { > * a TX interrupt, when the packet rate is above @pkt_rate_high. > * @rate_sample_interval: How often to do adaptive coalescing packet rate > * sampling, measured in seconds. Must not be zero. > + * @use_dim: Use DIM for IRQ coalescing, if adaptive coalescing is enabled. > * > * Each pair of (usecs, max_frames) fields specifies that interrupts > * should be coalesced until > @@ -483,6 +484,7 @@ struct ethtool_coalesce { > __u32 tx_coalesce_usecs_high; > __u32 tx_max_coalesced_frames_high; > __u32 rate_sample_interval; > + __u32 use_dim; > }; You cannot do this. static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr) { struct ethtool_coalesce coalesce; int ret; if (!dev->ethtool_ops->set_coalesce) return -EOPNOTSUPP; if (copy_from_user(&coalesce, useraddr, sizeof(coalesce))) return -EFAULT; An old ethtool binary is not going to set this extra last byte to anything meaningful. You cannot tell if you have an old or new user space, so you have no idea if it put anything into use_dim, or if it is random junk. You have to leave the IOCTL interface unchanged, and limit this new feature to the netlink API. > diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h > index e2bf36e..e3458d9 100644 > --- a/include/uapi/linux/ethtool_netlink.h > +++ b/include/uapi/linux/ethtool_netlink.h > @@ -366,6 +366,7 @@ enum { > ETHTOOL_A_COALESCE_TX_USECS_HIGH, /* u32 */ > ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH, /* u32 */ > ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL, /* u32 */ > + ETHTOOL_A_COALESCE_USE_DIM, /* u8 */ This appears to be a boolean? So /* flag */ would be better. Or do you think there is scope for a few different algorithms, and an enum would be better. If so, you should add the enum with the two current options. Andrew